Theoretical part
ActionManager is a singleton class that manages all actions. Usually you don't need to use this class directly. In most cases, you will use node's interface, which provides a more friendly package but there are some cases where you might need to use this singleton. Example:
- When you want to run an action, but the target is not a node type.
- When you want to pause/resume the action.
Code section
void Addaction (Action *action, Node *target, BOOL paused)
Adds an action that also needs to provide the target object for the action and whether the target object is paused as a parameter. When the target State paused to true, the action will not be executed.
Instance:
Auto Director = director::getinstance (); Directortrue);
void Removeallactions ()
Deletes all actions for all target objects.
void Removeallactionsfromtarget (Node *target)
Remove all actions from a specific target. All actions that are part of the target will be deleted.
void Removeaction (Action *action)
Deletes an action.
void Removeactionbytag (int tag, Node *target)
Deleting an action for a specific tag tag under the target object will delete the first match to the action.
void Removeallactionsbytag (int tag, Node *target)
Removes all actions for a specific tag tag under the target object.
void removeactionsbyflags (unsigned int flags, Node *target)
Delete a specific tag group action under a target object
Action * Getactionbytag (int tag, const Node *target) const
Gets an action from the target object and tag.
ssize_t getnumberofrunningactionsintarget (const Node *target) const
Returns the number of all running actions under the specified target. A combined action is counted as an action. Example:
ssize_t Numberofrunningactionsintarget (Node *target) const
void Pausetarget (Node *target)
Pause target object: All running actions and newly added actions will be paused.
void Resumetarget (Node *target)
Let the target object resume running. All paused actions in the execution sequence will resume running.
Instance:
Auto Director = director::getinstance (); Director->getactionmanager ()->resumetarget (node);
vector< Node * > Pauseallrunningactions ()
Pauses all running actions, returning a list of target objects to which an action is paused.
void Resumetargets (const vector< Node * > &targetstoresume)
Let a set of target objects resume running.
Cocos Code Study (one) ActionManager class learning Notes