title: cocos2d sprite repeat animation forever
body: <p>In my iOS game, I hope the hero keep running until screen is touched and the hero should jump. So I write:<br>
  In .h file:    </p>
  
  <pre><code>@interface Hero : CCSprite {
      CCSprite *_hero;
      id _keepRunning;
  }
  @property(nonatomic,retain) id keepRunning;
  </code></pre>
  
  <p>In .m file:    </p>
  
  <pre><code>@synthesize keepRunning = _keepRunning;
  -(id) init {
      _keepRunning = [CCRepeatForever actionWithAction:[CCAnimate actionWithSpriteSequence:@"heroRun%04d.png"
                                                                                 numFrames:30
                                                                                     delay:0.02f
                                                                      restoreOriginalFrame:NO]];        
  }
  </code></pre>
  
  <p>Then when the game starts, I call run () method:</p>
  
  <pre><code>-(void) run {
      [_hero stopAllActions];
      [_hero runAction:_keepRunning];
      _heroState = RUNNING;
  }
  </code></pre>
  
  <p>Then I found <code>CCAnimate actionWithSpriteSequence: numFrames: delay: restoreOriginalFrame:</code> is deprecated in cocos2d v2.0. So my question is, in cocos2d v2.0, how can I implement this animation? Namely, keep my hero running? Thank you!<br>
  EDIT:<br>
  I have tried this:    </p>
  
  <pre><code>-(CCAnimation*) getMyAnimationWithFramesName:(NSString*)nameFormat numFrames:(int)numFrames delay:(float)delay {
      NSMutableArray *frames = [[NSMutableArray alloc] init];
      for (int i = 1; i &lt;= numFrames; i++) {
          NSString *frameName = [NSString stringWithFormat:nameFormat,i];
          [frames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:frameName]];
      }
      CCAnimation *ani = [CCAnimation animationWithSpriteFrames:frames delay:delay];
      return ani;
  }
  </code></pre>
  
  <p>Then in init ():    </p>
  
  <pre><code>_keepRunning = [self getMyAnimationWithFramesName:@"heroRun%04d.png" numFrames:30 delay:0.02f];
  </code></pre>
  
  <p>and in run ():</p>
  
  <pre><code>[_hero runAction:[CCAnimate actionWithAnimation:_keepRunning]];
  </code></pre>
  
  <p>But it still doesn't work. What should I do?</p>