Actions are like orders given to any CCNode object. These actions usually modify some of the object's attributes like position, rotation, scale, etc. If these attributes are modified during a period of time, they are CCIntervalAction actions, otherwise they are CCInstantAction actions.
For example, the CCMoveBy action modifies the position property during a period of time, hence, it is a subclass of CCIntervalAction.
Example:
# Move a sprite 50 pixels to the right, and 10 pixels to the top over 2 seconds. [sprite runAction: [CCMoveBy actionWithDuration:2 position:ccp(50,10)]];
The CCIntervalAction actions have some interesting properties:
ActionsEaseTest.m example for more info)[action reverse]) that executes the action in the opposite direction.
You can pause/resume all actions by using the CCActionManager:
# Pause actions [[CCActionManager sharedManager ] pauseAllActionsForTarget:sprite ] ; # resume actions [[CCActionManager sharedManager ] resumeAllActionsForTarget:sprite ] ;
Basic actions are the ones that modify basic properties like:
Example:
CGSize s = [[CCDirector sharedDirector] winSize]; id actionTo = [CCMoveTo actionWithDuration: 2 position:ccp(s.width-40, s.height-40)]; id actionBy = [CCMoveBy actionWithDuration:2 position: ccp(80,80)]; [sprite1 runAction: actionTo]; [sprite2 runAction:actionBy];
Almost all actions have the reverse method implemented. Basically it creates a new action with the reverse behavior.
Example:
id move = [CCMoveBy actionWithDuration:2 position: ccp(80,80)]; id move_reverse = [move reverse];
The move_reverse action will be a CCMoveBy action of duration 2, but with the position value of ccp(-80,-80).