2012年6月15日 星期五

Cocos2d 2.0 Composite Actions

You may compose your actions using the following actions:
  • Sequence Action - CCSequence
  • Spawn Action - CCSpawn
  • Repeat Action - CCRepeat
  • RepeatForever Action - CCRepeatForever

Composite Actions

Sequence

  • CCSequence
          The CCSequence action is a list of actions. The actions are executed in the order that they are defined.

          example:
      id scale = [CCScaleBy actionWithDuration:0.5 scaleX:1.25f scaleY:0.8f];
      id scale_reverse = [scale reverse];
      [mySprite runAction:[CCSequence actions:scale, scale_reverse, scale_reverse, scale, nil]];

Spawn


  • CCSpawn
          The CCSpawn action lets you run several actions at the same time. The duration of the CCSpawn action will be the duration of the longest sub-action.

          example:
      [mySprite runAction:[CCSpawn actions:
             [CCMoveTo actionWithDuration:4 position:ccp(40, 40)],
             [CCRotateBy actionWithDuration:2 angle:360],
             [CCBlink actionWithDuration:3 blinks:12],
             nil]];

Repeat

  • CCRepeat
          The CCRepeat action lets you repeat an action a limited number of times.

          example:
      id scale = [CCScaleBy actionWithDuration:0.5 scaleX:1.25f scaleY:0.8f];
      id scale_reverse = [scale reverse];
      [mySprite runAction:[CCRepeat actionWithAction:[CCSequence actions:scale, scale_reverse, scale_reverse, scale, nil] times:5]];

RepeatForever

  • CCRepeatForever
          The CCRepeatForever action is a special action. Since it will repeat an action forever, its duration can't be measured.

          example:
      [mySprite runAction:[CCRepeatForever actionWithAction:[CCSequence actions:scale, scale_reverse, scale_reverse, scale, nil]]];

沒有留言:

張貼留言