2012年6月19日 星期二

Cocos2d 2.0 Ease Actions


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 for 2 seconds, then the total will still be 2 seconds.

The Ease actions alter the linearity of the time. The original inner actions with constant speed looks like:

The inner actions includes: move, rotate, scale, jump, etc.

Ease actions can accelerate or decelerate the inner action.


Ease 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 at the beginning and at the end.

Ease

  • CCEaseIn
     
          Acceleration at the beginning.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseIn actionWithAction:move rate:3];
      [mySprite runAction:ease];

  • CCEaseOut

      
          acceleration at the end.



          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseOut actionWithAction:move rate:3];
      [mySprite runAction:ease];

  • CCEaseInOut

      
          Acceleration at the beginning/end.



          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseInOut actionWithAction:move rate:3];       [mySprite runAction:ease];

EaseExponential

  • CCEaseExponentialIn

      
          Acceleration at the beginning with Exponential Curve.


          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseExponentialIn actionWithAction:move];
      [mySprite runAction:ease];

  • CCEaseExponentialOut
      
          Acceleration at the end with Exponential Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseExponentialOut actionWithAction:move];
      [mySprite runAction:ease];

  • CCEaseExponentialInOut
      
          Acceleration at the beginning/end with Exponential Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseExponentialInOut actionWithAction:move];
      [mySprite runAction:ease];

EaseSine

  • CCEaseSineIn
      
          Acceleration at the beginning with Sine Curve.


          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseSineIn actionWithAction:move];
      [mySprite runAction:ease];

  • CCEaseSineOut

      
          Acceleration at the end with Sine Curve.


          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseSineOut actionWithAction:move];
      [mySprite runAction:ease];

  • CCEaseSineInOut

      

          Acceleration at the beginning/end with Sine Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseSineInOut actionWithAction:move];
      [mySprite runAction:ease];

Elastic

  • CCEaseElasticIn
      

          Acceleration at the beginning with Elastic Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseElasticIn actionWithAction:move period:0.3f];
      [mySprite runAction:ease];
  • CCEaseElasticOut
      

          Acceleration at the end with Elastic Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseElasticOut actionWithAction:move  period:0.45f ];
      [mySprite runAction:ease];
  • CCEaseElasticInOut
      
          Acceleration at the beginning/end with Elastic Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseElasticInOut actionWithAction:move  period:0.6f ];
      [mySprite runAction:ease];

Bounce

  • CCEaseBounceIn
      
          Acceleration at the beginning with Bounce Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseBouncIn actionWithAction:move];
      [mySprite runAction:ease];
  • CCEaseBounceOut

      
          Acceleration at the end with Bounce Curve.
          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseBouncOut actionWithAction:move];
      [mySprite runAction:ease];
  • CCEaseBounceInOut
      
          Acceleration at the beginning/end with Bounce Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseBouncInOut actionWithAction:move];
      [mySprite runAction:ease];

Back

  • CCEaseBackIn
      
          Acceleration at the beginning with Back Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseBackIn actionWithAction:move];
      [mySprite runAction:ease];

  • CCEaseBackOut
      
          Acceleration at the end with Back Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseBackOut actionWithAction:move];
      [mySprite runAction:ease];
  • CCEaseBackInOut
      
          Acceleration at the beginning/end with Back Curve.

          example:
      id move = [CCMoveTo actionWithDuration:2 position:location];
      id ease = [CCEaseBackInOut actionWithAction:move];
      [mySprite runAction:ease];

沒有留言:

張貼留言