Sunday, July 5, 2009

[iPhone - cocos2d] execute N-actions at once.

Is there any way to execute N-actions at once ?

The answer is 'Yes, there is ".

There is a Class named 'Spawn' in Cocos2d library.

Let's see the Documentation of 'Spawn' Class.

@interface Spawn : IntervalAction
{
FiniteTimeAction *one;
FiniteTimeAction *two;
}

'Spawn' is an one of sub Class of 'IntervalAction'.
And basically it can have only 2 action.

But, as you can see, there is a class method names "actions:".
That method support N-Actions. How is it possible ?
The answer is simple, Spawn object can have other Spawn object as its property.

Let me show some example.

Action *action = [Spawn actions:[RotateBy actionWithDuration:aValue angle:180], [FadeIn actionWithDuration:aValue], [ScaleTo actionWithDuration:aValue scale:1.5],nil];

Spawn have 'RotateBy' and ' FadeIn' and 'ScaleTo'

And those actions will be executed at a time.

Enjoy your development :)

No comments:

Post a Comment