在Node类有关动作的函数:
Action *runAction(Action * action);
void stopAction(Action * action);
void stopAllActions();
void stopActionByTag(int tag);
瞬时动作
Action
FiniteTimeAction受时间限制的动作类
ActionInstant瞬时动作
Place FlipX FlipY Hide Show ToggleVisibility 类
void MyAction::goMenu(Ref *Spender)
{
log("tag=%i", this->getTag());
Size size = Director::getInstance()->getVisibleSize();
Vec2 p = Vec2(CCRANDOM_0_1()*size.width, CCRANDOM_0_1()*size.height);
switch(this->getTag()){
case PLACE_TAG:
sprite->runAction(Place::create(p));
break;
case FLIPX_TAG:
sprite->runAction(FlipX::create(true));
break;
case FLIPY_TAG:
sprite->runAction(FlipY::create(true));
break;
case HIDE_SHOW_TAG:
if (hiddenFlag) {
sprite->runAction(Hide::create());
hiddenFlag = false;
}
else {
sprite->runAction(Show::create());
hiddenFlag = true;
}
break;
case TOGGLE_TAG:
sprite->runAction(ToggleVisibility::create());
break;
default:
break;
}
}
间隔动作
Action
FiniteTimeAction受时间限制的动作类
ActionInterval间隔动作
MoveTo MoveBy等子类
sprite->runAction(MoveTo::create(2,Vec2(100,100)));