Feel free to fix/add documentation to the wiki

Actions: Ease

Ease actions are special composition actions that alter the time of the inner action. In the Flash world they are often called Tweening or Easing actions.

These actions modify the speed of the inner action, but they don't modify the total running time. If the inner action lasts 5 seconds, then the total will continue to be 5 seconds.

The Ease actions alter the linearity of the time.

For example they can accelerate or decelerate the inner action.

These actions can be classified in 3 types:

  • In actions: The acceleration is at the beginning of the action
  • Out actions: The acceleration is at the end of the action
  • InOut actions: The acceleration is that beggining/end and in the end.

For more information about easing or tweening actions, visit any of these pages:

Ease actions

They accelerate the inner action using this formula:

-(void) update:(ccTime) t
{
   [inner update: powf(t,rate)];
}

Variations:

  • CCEaseIn: acceleration at the beginning
  • CCEaseOut: acceleration at the end
  • CCEaseInOut: acceleration at the beginning / end

The rate argument indicates the acceleration rate.

Example:

// acceleration at the beginning
id action = [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease = [CCEaseIn actionWithAction:action rate:2];
[sprite runAction: ease];
 
// acceleration at the end
id action = [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease = [CCEaseOut actionWithAction:action rate:2];
[sprite runAction: ease];
 
// acceleration at the beginning / end
id action = [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease = [CCEaseInOut actionWithAction:action rate:2];
[sprite runAction: ease];

EaseExponential actions

Available exponential actions:

  • CCEaseExponentialIn
  • CCEaseExponentialOut
  • CCEaseExponentialInOut

Example:

id scaleAction = [CCScaleTo actionWithDuration:2.5 scale:.8];
id easeAction = [CCEaseExponentialIn actionWithAction:scaleAction];
[label runAction: easeAction];

FIXME

EaseSine actions

Available sine actions:

  • CCEaseSineIn
  • CCEaseSineOut
  • CCEaseSineInOut

FIXME

EaseElastic actions

These actions alters the time simulating an elastic. Elastic actions will use time values greater than 1 and lower than 0, so the inner action should be prepared to handle this special values.

Also some values will be triggered more than once (this function is not bijective), so again, the inner action should be prepared to handle this values. Simple actions like CCMoveBy, CCScaleBy, CCRotateBy work OK with EaseElastic actions, but the CCSequence or CCSpawn actions might have unexpected results.

Available elastic actions:

  • CCEaseElasticIn
  • CCEaseElasticOut
  • CCEaseElasticInOut

Examples:

 
// 'period' is how elastic is the action.
// recommended values: between 0.3 and 0.45
 
// Elastic at the beginning
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseElasticIn actionWithAction:move period:0.3f];
[sprite runAction: action];
 
// Elastic at the end
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseElasticOut actionWithAction:move period:0.3f];
[sprite runAction: action];
 
// Elastic at the beginning and at the end
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseElasticInOut actionWithAction:move period:0.3f];
[sprite runAction: action];

EaseBounce actions

EaseBounce actions simulates a bouncing effect.

Some time values will be triggered more than once (this function is not bijective), so the inner action should be prepared to handle this values. Simple actions like CCMoveBy, CCScaleBy, CCRotateBy work OK with EaseBounce actions, but the CCSequence or CCSpawn actions might have unexpected results.

Available bounce actions:

  • CCEaseBounceIn
  • CCEaseBounceOut
  • CCEaseBounceInOut

Examples:

 
// Bounce at the beginning
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseBounceIn actionWithAction:move];
[sprite runAction: action];
 
// Bounce at the end
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseBounceOut actionWithAction:move];
[sprite runAction: action];
 
// Bounce at the beginning and at the end
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseBounceInOut actionWithAction:move];
[sprite runAction: action];

EaseBack actions

Some time values will be triggered more than once (this function is not bijective), so the inner action should be prepared to handle this values. Simple actions like CCMoveBy, CCScaleBy, CCRotateBy work OK with EaseBack actions, but the CCSequence or CCSpawn actions might have unexpected results.

Available Back actions:

  • CCEaseBackIn
  • CCEaseBackOut
  • CCEaseBackInOut

Examples:

 
// Back at the beginning
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseBackIn actionWithAction:move];
[sprite runAction: action];
 
// Back at the end
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseBackOut actionWithAction:move];
[sprite runAction: action];
 
// Back at the beginning and at the end
id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCEaseBackInOut actionWithAction:move];
[sprite runAction: action];

Actions: Speed

Speed action

The CCSpeed action modifies the duration of the inner action.

id move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action = [CCSpeed actionWithAction: move speed:1.0f];   // no speed modification
 
// but you can modify the speed later
[action setSpeed: 2.5f]; // speed is 2.5 faster
 
[action setSpeed: 0.5f]; // speed is 0.5 faster (it means 2 times slower)