IPhone gamesDevelopmentCocos2DMediumActionsIs the content to be introduced in this article, mainly to learnActions. AsIphone gamesDuring development, you should not miss any useful article. Let's talk about it later. Let's take a look at the details.
Sequence
Ordered actions allow you to create a series of actions that will be executed in order.
- 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]];
Action1 will be executed first. When action1 is executed, action2 will be executed. When action2 ends, it is action3.
Note: This action cannot be an infinite time. For example, you cannot add an action that repeats to the action sequence forever.
Spawn concurrency
This action allows you to run multiple actions at the same time. The duration of this operation is the longest time of the sub-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 already exists.
This repeated Action allows you to repeat an Action for a limited number of times.
- 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 always repeats
Repeating this action forever is a special action that will continue. Because its time cannot be measured.
- id a1 = [MoveBy actionWithDuration:1 position:ccp(150,0)];
- id action2 = [RepeatForever actionWithAction:
- [Sequence actions: [[a1 copy] autorelease], [a1 reverse], nil] ];
- [sprite runAction:action2];
Note: This action that is always repeated is not a valid IntervalAction and cannot be placed in a sequence action.
Summary: AboutIPhone gamesDevelopmentCocos2DMediumActionsI hope this article will help you!