CCActionSpawn Class Reference

Inherits from CCActionInterval : CCActionFiniteTime : CCAction : NSObject
Conforms to NSCopying
Declared in CCActionInterval.h

Overview

This action can be used in a CCActionSequence to allow the sequence to spawn 2 or more actions that run in parallel to the sequence.

Usage example with a sequence, assuming actionX and spawnActionX are previously declared, assigned and initialized with a CCActionFiniteTime or subclass:

id spawn = [CCActionSpawn actionsWithArray:@[spawnAction1, spawnAction2]];

NSArray* actionsArray = @[action1, spawn, action2];
id sequence = [CCActionSequence actionsWithArray:actionsArray];
[self runAction:sequence];

This will run action1 to completion. Then spawnAction1 and spawnAction2 will run in parallel to completion. Then action4 will run after both spawnAction1 and spawnAction2 have run to completion. Note that if spawnAction1 and spawnAction2 have different duration, the duration of the longer running action will become the duration of the spawn action.

Note: To generally run actions in parallel you can simply call runAction: for each action rather than creating a sequence with a spawn action. For example, this suffices to run two actions in parallel:

[self runAction:action1];
[self runAction:action2];

Note: It is not meaningful to use CCActionSpawn with just one action.

Creating a Spawn Action

+ actions:

Helper constructor to create an array of spawned actions. Usage: id spawn = [CCActionSpawn actions:spawnAction1, spawnAction2, nil];

+ (id)actions:(CCActionFiniteTime *)action1, ...

Parameters

action1

First action to spawn.

...

Nil terminated list of action to spawn.

Return Value

New action spawn.

Discussion

Warning: List must be nil-terminated. Not doing so results in “Missing sentinal in method dispatch” warning, which will crash the app if ignored.

See Also

Declared In

CCActionInterval.h

+ actions:vaList:

Helper constructor to create an array of spawned actions.

+ (id)actions:(CCActionFiniteTime *)action1 vaList:(va_list)args

Parameters

action1

Action to spawn.

args

C++ style list of actions.

Return Value

New action spawn.

Discussion

Note: The usual C/C++ memory management and va_list usage principles apply.

See Also

Declared In

CCActionInterval.h

+ actionWithArray:

Helper constructor to create an array of spawned actions given an array. Recommended, safe initializer.

+ (id)actionWithArray:(NSArray *)arrayOfActions

Parameters

arrayOfActions

Array of actions to spawn.

Return Value

New action spawn.

See Also

Declared In

CCActionInterval.h