0
votes

what is the recommended approach to playing animation sequences that include as the end-stone a repeating animation. For example, here are a few scenarios:

  1. Sprite appears on screen, play intro animation, then repeat forever an "idle" animation
  2. Sprite with "idle" animation performs some action thus I need to play some other specific animation at the end of which the sprite should start idling again.

CCSequence does not let me do this, as the "idle" animation is wrapped into a CCRepeatForever. If I simply chose to run whatever animation I like above the idling animation I get frame flickering (looks like both animations are played at the same time) — sucks.

All animations are inside CCAnimationCache ... any advice will be highly appreciated.

1

1 Answers

1
votes

I don't know if there is a recommended approach. What I would do is running the second animation (the repeating one) with a delay or by chaining it to the first through the animation completion handler.

An easy way to do the chaining is adding at the end of your first animation a CCCallFunc action, like here, that will call trigger the second animation:

CCActionInterval* action = [CCSequence actions:
           [CCProgressFromTo actionWithDuration:duration_ from:100.f to:0.f],
           [CCCallFunc actionWithTarget:self selector:@selector(startSecondAction)],
           nil ];