title: Play an animation from random point in cocos2d
body: <p>Imagine a game with a top-down view. Right from the start there are 10 monsters on the screen. Each one is represented by a <code>CCSprite</code> with a continuous <code>CCAnimation</code> applied to it.</p>
  
  <p>If I just run animations on all monsters at once with <code>runAction:[CCAnimate ...]</code>, they will all animate in sync. The result I want to get is to start every animation at a random point between 0 and its duration. Once an animation reaches its endpoint, it should start from the beginning and proceed as usual, looping forever.</p>
  
  <p>I have not found a way to achieve this result without modifying the cocos2d source code. And still, I can't get appropriate result for both <code>CCRepeatForever</code> and <code>CCSequence</code> (when I want to loop two or more consecutive animations with. The code for the latter case:</p>
  
  <pre><code>CCAnimate *idleAction = [CCAnimate actionWithAnimation:...];
  CCAnimate *moveAction = [CCAnimate actionWithAnimation:...];
  
  // ...
  
  - (void)playIdleAnimation
  {
      [mySprite runAction:
       [CCSequence actions:idleAction,
        [CCCallFunc actionWithTarget:self selector:@selector(playMoveAnimation)],
        nil]];
  }
  
  - (void)playMoveAnimation
  {
      [mySprite runAction:
       [CCSequence actions:moveAction,
        [CCCallFunc actionWithTarget:self selector:@selector(playIdleAnimation)]
        nil]];
  }
  </code></pre>
  
  <p>Note that I cannot use <code>[CCSequence actions:idleAction, moveAction, nil]</code> because each of the two actions may be repeated arbitrary number of times before switching to the other one.</p>
  
  <p>I will appreciate any thoughts on the subject. Thank you.</p>