瞬时动作
瞬时动作不需要时间,立即完成
[cpp]
//放置,=setPosition()
pRole->runAction(CCPlace::create(ccp(300,300)));
//隐藏,=setVisible(false)
pRole->runAction(CCHide::create());
//显示,=setVisible(true)
pRole->runAction(CCShow::create());
//水平翻转,=setFlipX(true)
pRole->runAction(CCFlipX::create(true));
//垂直翻转,=setFlipY(true)
pRole->runAction(CCFlipY::create(true));
延时动作
[cpp]
//移动到,1s,
pRole->runAction(CCMoveTo::create(1,ccp(300,300)));
//跳跃到,1s,高度50,分为5步
pRole->runAction(CCJumpTo::create(1,ccp(300,300),50,5));
//放大到,1s,2倍大小
pRole->runAction(CCScaleTo::create(1,2));
//旋转到,1s,90度
pRole->runAction(CCRotateTo::create(1,90));
//闪烁,1s,5下
pRole->runAction(CCBlink::create(1,5));
//色调变化到,1s,RGB
pRole->runAction(CCTintTo::create(1,100,100,100));
//变暗到,1s,透明度
pRole->runAction(CCFadeTo::create(1,50));
//由无变亮,1s,
pRole->runAction(CCFadeIn::create(1));
//由亮变无,1s,
pRole->runAction(CCFadeOut::create(1));
//水平翻转,1s
pRole->runAction(CCFlipX3D::create(1));
重复动作
[cpp]
//重复执行
pRole->runAction(CCRepeat::create(CCFlipX3D::create(1),2));
//无限重复
pRole->runAction(CCRepeatForever::create(CCFlipX3D::create(1)));
反动作
[cpp]
//反动作,通常只有 CCXXXBy支持
pRole->runAction(CCSequence::create(CCMoveBy::create(1,ccp(50,50)),CCMoveBy::create(1,ccp(50,50))->reverse(),NULL));
连续动作
[cpp]
//连续动作
CCFlipX3D* flip3d=CCFlipX3D::create(1);
CCBlink* blink=CCBlink::create(1,2);
CCScaleTo* scaleTo=CCScaleTo::create(1,2);
pRole->runAction(CCSequence::create(flip3d,blink ,scaleTo,NULL));
同步动作
[cpp]
//同步动作,确保动作可以同步执行,
CCRotateTo* roteTo=CCRotateTo::create(1,90);
CCFadeTo* fadeTo=CCFadeTo::create(1,50);
pRole->runAction(CCSpawn::create(roteTo,fadeTo ,NULL));