Repeat和RepeatForever
Sprite* sprite=Sprite::create("sprite.png"); sprite->setPosition(Point(visibleSize.width/2,visibleSize.height/2)); this->addChild(sprite,1); JumpBy* jumpBy=JumpBy::create(3.0f,Point(50,1),100,1); //RepeatForever* repeatforeverAction=RepeatForever::create(jumpBy); Repeat* repeatAction=Repeat::create(jumpBy,3); sprite->runAction(repeatAction);
Sequence和Spawn
Sprite* sprite=Sprite::create("sprite.png"); sprite->setPosition(Point(visibleSize.width/2,1); MoveBy* moveBy=MoveBy::create(2.2f,Point(40,20)); JumpBy* jumpBy=JumpBy::create(3.0f,5); RotateBy* rotateBy=RotateBy::create(2.5f,220,10); Action* action=Spawn::create(moveBy,jumpBy,rotateBy,NULL); sprite->runAction(action);
Action是所有动作额父类,Spawn也是一个动作,只不过这个动作又可以包含若干个动作,最后一个参数是NULL值,因为Spawn的create函数参数是可变参数,需要用NULL值表示结束。.
Seqence是动作一个接着一个执行;
Spawn是动作一起执行。