备注:只说明自己暂时用到的内容
FateIn FateOut 淡入淡出效果事件,备注:FateIn动作,需要设置前置的透明度,否则不会有效果
DelayTime 延迟动作
CCCallFunc 回调函数
CCSequence 序列动作,将动作依次执行依次,需要最后一个参数为NULL
CCRepeat 重复动作,重复动作一定的次数
CCRepeatForever 不停的重复动作
CCEaseSineOut 一个速度逐渐变慢的动作
CCMoveBy 移动一定的距离
Spawn 同步执行动作 备注:如果一个动作的执行时间比另外一个事件长,会出现一个短事件动作先结束的情况,如果使用了RepeatForever ,那么这个循环的动作会卡住!
reverse() 获得这个动作的反动作
runAction 执行动作
StopAction 停止动作
CCRepeat* HelloWorld::Disapper() {
CCFiniteTimeAction *fadeOut = CCFadeOut::create(1.5);
CCFiniteTimeAction *fadeIn = CCFadeIn::create(0.5);
CCFiniteTimeAction *delay = CCDelayTime::create(1.0);
auto callbak = CCCallFunc::create(this,callfunc_selector(HelloWorld::test2));
auto disappear = CCRepeat::create(CCSequence::create(fadeIn, delay, fadeOut, callbak,NULL), 1);
return disappear;
}
CCFiniteTimeAction* moveUp = CCEaseSineOut::create(CCMoveBy::create(1, ccp(0, 100)));
CCFiniteTimeAction* moveDown = moveUp->reverse();
//auto jump = CCRepeat::create(CCSequence::create(moveUp,moveDown),0);
auto jump = CCRepeatForever::create(CCSequence::create(moveUp, moveDown, NULL));
monster_sprite->runAction(jump);
TargetedAction不通过runAction绑定到target的node中,另外备注一下,同一个动作只能给一个对象使用,如果被使用过的动作就不能执行,需要clone一份
Sprite* red = Sprite::create("red_block.png");
red->setPosition(100, 100);
this->addChild(red);
MoveTo* move = MoveTo::create(1.0f, Point(400, 400));
TargetedAction* targeted = TargetedAction::create(red, move);
Sprite* yellow = Sprite::create("yellow_block.png");
yellow->setPosition(100, 200);
this->addChild(yellow);
CallFunc* back = CallFunc::create(CC_CALLBACK_0(tzot::test,this));
Spawn* sw = Spawn::create(move->clone(), targeted,NULL);
yellow->runAction(Sequence::create(sw, back,NULL));