title: Change Animation Cocos2d
body: <p>I have some question about Animation;
  I have class with animation;</p>
  
  <pre><code>@interface Player : CCNode{
  
      CCSprite *_player;
      CCSpriteBatchNode *spriteSheet;
      CCAction *walkAction;
      CCAnimation *walkAnim;
  
  
      int playerSpeed;
      int xPos;
      int yPos;
      int state;
      int currentAnim;
  }
  @property (nonatomic, retain) CCSprite *_player;
  
  
  
  -(id)init {
  
      if( (self=[super init] )) {
  
          [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"duckAnimDown.plist"];
          [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"DuckAnimTurn.plist"];
          [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"duckAnimUp.plist"];
  
  
  
          currentAnim = 0;
          state = 0;
          [self chekState];
      }
      return self;
  }
  -(void)setState:(int)st {
  
      state = st;
      [self chekState];
  }
  -(void)chekState{
  
  
      [self stopAllActions];
      walkAnim = nil;
  
  
      if (state == 1 &amp;&amp; currentAnim != state) {
          [spriteSheet removeChild:_player cleanup:YES];
          spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"duckAnimDown.png"];
          NSMutableArray *walkAnimFrames = [NSMutableArray array];
          for (int i = 1; i &lt;= 12 ; ++i) {
              [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"duck_down%d.png", i]]];
          }
          walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.04f];//0.06
          _player = [CCSprite spriteWithSpriteFrameName:@"duck_down1.png"];
          walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
  
      }
      if (state == 2 &amp;&amp; currentAnim != state) {
          [spriteSheet removeChild:_player cleanup:YES];
          spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"DuckAnimTurn.png"];
          NSMutableArray *walkAnimFrames = [NSMutableArray array];
          for (int i = 1; i &lt;= 10 ; ++i) {
              [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"duck_turn%d.png", i]]];
          }
          walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.04f];//0.06
          _player = [CCSprite spriteWithSpriteFrameName:@"duck_turn1.png"];
          walkAction = [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO];
  
      }
      if (state == 3 &amp;&amp; currentAnim != state) {
  
          [spriteSheet removeChild:_player cleanup:YES];
          spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"duckAnimUp.png"];
          NSMutableArray *walkAnimFrames = [NSMutableArray array];
  
          for (int i = 1; i &lt;= 13 ; ++i) {
              [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"duck_up%d.png", i]]];
          }
          walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.04f];//0.06
          _player = [CCSprite spriteWithSpriteFrameName:@"duck_up1.png"];
          walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
  
      }
      if (currentAnim != state) {
          [_player runAction:walkAction];
          [spriteSheet addChild:_player];
          [self addChild:spriteSheet];
          currentAnim = state;
      }
  
  
  
  }
  </code></pre>
  
  <p>I use this class in GameplayScene;</p>
  
  <pre><code>duckSprite = [Player node];
  </code></pre>
  
  <p>To change animation i call: <code>[duckSprite setState:2];</code></p>
  
  <p>It's ok, but when i change animation FPS are very low 20 - 25;
  What is wrong in my code?
  Thanks.</p>