title: Change sprite plist file in the init - cocos2d
body: <p>I am making a game in cocos2d and I have a knight character that I want to change the sprite for. So in my knight.m, I did this:</p>
  
  <pre><code>- (id)initWithKnightPicture {
  
          l1 = [NSString stringWithFormat:@"knightL3.png"];
          l1_plist = [NSString stringWithFormat:@"knightL3.plist"];
  
          self = [super initWithFile:l1];
  
  
      if (self) {
  
                  [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:l1_plist];
  
          // ************* RUNNING ANIMATION ********************
          animationFramesRun = [NSMutableArray array];
          for(int i = 1; i &lt;= 6; ++i) {
              [animationFramesRun addObject:
               [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"Level1-Run-hd-%d.png", i]]];
          }
      }
      return self;
  }
  
  - (void)update:(ccTime)delta
  {
      if ([[GameMechanics sharedGameMechanics] game].fatness &lt; 20) {
          l1 = [NSString stringWithFormat:@"knightL1.png"];
          l1_plist = [NSString stringWithFormat:@"knightL1.plist"];
      } else if ([[GameMechanics sharedGameMechanics] game].fatness &lt; 40) {
          l1 = [NSString stringWithFormat:@"knightL2.png"];
          l1_plist = [NSString stringWithFormat:@"knightL2.plist"];
      } else if ([[GameMechanics sharedGameMechanics] game].fatness &lt; 60) {
          l1 = [NSString stringWithFormat:@"knightL3.png"];
          l1_plist = [NSString stringWithFormat:@"knightL3.plist"];
      } else if ([[GameMechanics sharedGameMechanics] game].fatness &lt; 80) {
          l1 = [NSString stringWithFormat:@"knightL4.png"];
          l1_plist = [NSString stringWithFormat:@"knightL4.plist"];
      } else if ([[GameMechanics sharedGameMechanics] game].fatness &lt; 100) {
          l1 = [NSString stringWithFormat:@"knightL5.png"];
          l1_plist = [NSString stringWithFormat:@"knightL5.plist"];
      }
  }
  </code></pre>
  
  <p>So basically, I want the knight's sprite to change from <code>knightL1.plist</code> to <code>knightL2.plist</code> based on the fatness of the knight... So what I am doing in my code is, I am assigning the knight to be the string <code>l1</code> and assigning <code>l1</code> and <code>l1_plist</code> to be <code>knightL3</code> in the <code>init</code>. Then in my update method, I am changing <code>l1</code> and <code>l1_plist</code> to be a different string. The problem is, that if the fatness does exceed <code>80</code>, and I change the <code>l1</code> and <code>l1_plist</code> strings to be a different string, the sprite does not change from being <code>knightL4.plist</code> to <code>knightL5.plist</code>. So how can I make it so the knight changes based on the fatness as the game progresses?</p>
  
  <p>Thanks in advance!</p>