摘要:
//程序开始后延时2秒才开始addSprite函数scheduleOnce(schedule_selector(Issue1305::addSprite), 2);转到定义:void CCNode::scheduleOnce(SEL_SCHEDULE selector, float delay){ this->schedule(selector, 0.0f, 0, delay);}void Issue1305::addSprite(float dt){ m_pSpriteTmp->setPosition(ccp(250,250)); addChild(m_pSpriteTmp... 阅读全文
摘要:
CCSet *m_pPausedTargets;类的成员变量void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)void PauseResumeActions::onEnter(){ ActionsDemo::onEnter(); this->centerSprites(2); m_tamara->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360))); ... 阅读全文
摘要:
在class HelloWorld : public cocos2d::CCLayer中添加void draw();实现:void HelloWorld::draw(){ CCSize s = CCDirector::sharedDirector()->getWinSize(); CCPointArray *array = CCPointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(80, 80)); array->addControlPoint(c... 阅读全文
摘要:
CCCatmullRomBy:把某一对象以Catmull-Rom curve曲线移动一段距离 CCPointArray *array = CCPointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(80, 80)); array->addControlPoint(ccp(s.width - 80, 80)); array->addControlPoint(ccp(s.width - 80, s.height - 80)); array-... 阅读全文
摘要:
class CC_DLL CCCallFunc : public CCActionInstant //void Issue1305_2::onEnter(){ ActionsDemo::onEnter(); centerSprites(0); CCSprite *spr = CCSprite::create("Images/grossini.png"); spr->setPosition(ccp(200,200)); addChild(spr); CCMoveBy* act1 = CCMoveBy::create(2 ,ccp(0, 100)); //... 阅读全文
摘要:
改变动作执行对象CCTargetedAction通常默认的动作执行对象是调用runAction的对象,而CCTargetedAction可以改变动作执行对象。CCTargetedAction* t = CCTargetedAction::create(sprite2, moveto);sprite->runAction(CCSequence::create(moveto, t, moveto, NULL));sprite先moveto,然后sprite2执行moveto,最后sprite执行moveto。void ActionTargeted::onEnter(){ ActionsDem 阅读全文
摘要:
CCActionInterval* move1 = CCMoveBy::create(1, ccp(250,0)); CCActionInterval* move2 = CCMoveBy::create(1, ccp(0,50)); CCToggleVisibility* tog1 = new CCToggleVisibility(); CCToggleVisibility* tog2 = new CCToggleVisibility(); tog1->autorelease(); tog2->autorelease(); //目前的理解是夹... 阅读全文
摘要:
有限次执行一组动作和无限次执行一组动作void ActionRotateJerk::onEnter(){ ActionsDemo::onEnter(); centerSprites(2); CCFiniteTimeAction* seq = CCSequence::create( CCRotateTo::create(0.5f, -20), CCRotateTo::create(0.5f, 20), NULL); CCActionInterval* rep1 = CCRepeat::create(seq, 10); C... 阅读全文
摘要:
voidremoveFromParentAndCleanup(bool cleanup)//删除父节点中的当前节点并清除动作及回调函数void ActionCallFuncND::onEnter(){ ActionsDemo::onEnter(); centerSprites(1); CCFiniteTimeAction* action = CCSequence::create(CCMoveBy::create(2.0f, ccp(200,0)), CCCallFuncND::create(this, callfuncND_selector(ActionCall... 阅读全文
摘要:
CCFollow动作,可以让一个节点跟随另一个节点做位移。CCFollow经常用来设置layer跟随sprite,可以实现类似摄像机跟拍的效果效果是精灵在地图上移动,地图也会跟着移动,但是精灵仍然是在整个界面的中心位置CCSize s = CCDirector::sharedDirector()->getWinSize(); pSprite->setPosition(ccp(-200, s.height / 2)); CCActionInterval* move = CCMoveBy::create(2, ccp(s.width * 3, 0)); ... 阅读全文
摘要:
Cocos2d-x提供了一中根据球面坐标轨迹旋转的方式CCOrbitCameraCC_DEPRECATED_ATTRIBUTE static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);参数分别为旋转的时间,起始半径,半径差,起始z角,旋转z角差,起始x角,旋转x角差CCActionInterval* orbit1 = CCOrbitCamera::cre. 阅读全文
摘要:
void ActionDelayTime::onEnter(){ ActionsDemo::onEnter(); alignSpritesLeft(1); CCActionInterval* move = CCMoveBy::create(1, ccp(150,0)); CCFiniteTimeAction* action = CCSequence::create( move, CCDelayTime::create(2), move, NULL); m_grossini->runAction(action);}连续动作的反向动作void ActionReve... 阅读全文
摘要:
CCSize boxSize = CCSizeMake(100.0f, 100.0f); CCLayerColor *box = CCLayerColor::create(ccc4(255, 255, 0, 255)); box->setAnchorPoint(ccp(0, 0)); box->setPosition(ccp(190, 110)); box->setContentSize(boxSize);CCAnimation* animation = CCAnimation::create(); for( int i=1;iaddSpriteFrameWith... 阅读全文
摘要:
通过CCAnimation实例获取CCSpriteFrame,会出现类型转换问题。我们在创建一个animation的时候,经常遵循下面的步骤:1)create 一个CCArray对象A。2)通过A->addObject()添加CCSpriteFrame对象3)通过CCAnimation::createWithSpriteFrames(A, 0.2f)常见一个CCAnimation对象B。可以通过B->getFrames()获得一个CCArray*的指针A’,然后通过A’->ObjectAtIndex(0)获得第一个CCObject*类型的对象,称之为C。从表面上看,A’和A应 阅读全文