Game Development Reference
In-Depth Information
CCSequence* sequence = [CCSequence actions:tint1, tint2, tint3, nil];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:sequence];
CCSpeed* speedAction = [CCSpeed actionWithAction:repeat speed:0.75f];
[label runAction:speedAction];
Note As with menu items, a list of actions always ends with nil . If you forget
to add nil as the last parameter, the line creating the CCSequence will
Ease Actions
Actions become even more powerful when you use actions based on the CCAc-
tionEase class. Ease actions allow you to modify the effect of an action over time.
For example, if you use a CCMoveTo action on a node, the node will move the whole
distance at the same speed until it's arrived. With CCActionEase , you can have the
node start slow and speed up toward the target, or vice versa. Or you can let it move
past the target location a little and then bounce back. To see easing in action, check out
this demo application that runs in a web browser:
ing/easing_demo.html .
Ease actions create very dynamic animations that are normally very time-consuming to
implement. The following code shows how to use an ease action to modify the behavi-
or of a regular action. The rate parameter determines how pronounced the effect of
the ease action is and should be greater than 1 to see any effect.
// I want myNode to move to 100, 200 and arrive there in 3 seconds
CCMoveTo* move = [CCMoveTo actionWithDuration:3 position:CGPointMake(100, 200)];
// this time the node should slowly speed up and then slow down as it moves
CCEaseInOut* ease = [CCEaseInOut actionWithAction:move rate:4];
[myNode runAction:ease];
Note In the preceding example, the ease action is run on the node, not the
move action. It's all too easy to forget to change the runAction line when
you're working with actions—a common mistake by even to the most experien-
Search Nedrilad ::

Custom Search