Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.

Actions

Actions

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:

  • They can be accelerated using the time-altered actions
    • CCEaseIn
    • CCEaseOut
    • CCEaseInOut
    • CCSpeed
    • Etc. (See the ActionsEaseTest.m example for more info)
  • All the relative actions (the ones ending in 'By') and some absolute actions (the ones ending in 'To') have a reverse action ([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

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];

Reverse Action

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).

prog_guide/actions.txt · Last modified: 2013/01/07 19:33 by lmavila
Trace: actions
Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0