There are some actions that let you compose actions.
Sequence action
Spawn action
Repeat action
RepeatForever action
Sequence 顺序
顺序Action能够让你创建一系列的动作,这些动作将会按着顺序被执行。
Example:
id action1 = [MoveTo actionWithDuration:2 position:ccp(100,100)];
id action2 = [MoveBy actionWithDuration:2 position: ccp(80,80)];
id action3 = [MoveBy actionWithDuration:2 position: ccp(0,80)];
[sprite runAction: [Sequence actions:action1, action2, action3, nil]];
The action1 will be executed first. When action1 finishes, then action2 will be executed. And when action2 finishes, only then action3will be executed.
*IMPORTANT:* The inner actions should have a non infinity time (eg: You can't add a RepeatForever action in a Sequence action).
Action1 将会被首先执行,当action1执行结束,action2将会被执行,当action2结束,是action3。
注意:这个action不能是一个无限的时间。例如,你不能增加一个重复到永远的action到这个顺序action里面。
Spawn 并发?
这个action使得你可以在同一个时间运行多个action。这个动做的持续时间是子action的最长时间。
id action = [Spawn actions:
[JumpBy actionWithDuration:2 position:ccp(300,0) height:50 jumps:4],
[RotateBy actionWithDuration: 2 angle: 720],nil];
[sprite runAction:action];
Repeat 重复
这个重复Action可以让你有限次数的重复一个动作。 Example:
id a1 = [MoveBy actionWithDuration:1 position:ccp(150,0)];
id action1 = [Repeat actionWithAction:
[Sequence actions: [Place actionWithPosition:ccp(60,60)], a1, nil]times:3];
[sprite runAction:action1];
RepeatForever 永远重复
永远重复这个动作是一个特殊的action,它将会一直持续下去。因为它的时间是无法测量的。
Example:
id a1 = [MoveBy actionWithDuration:1 position:ccp(150,0)];
id action2 = [RepeatForever actionWithAction:
[Sequence actions: [[a1 copy] autorelease], [a1 reverse], nil] ];
[sprite runAction:action2];
注意:永远重复的这个action不是一个有效的IntervalAction,他不能被放置在一个序列action里面。
出处:http://alexliu.cnblogs.com/