title: EXC_BAD_ACCESS on IPhone Cocos2d
body: <p>I Have the following code:</p>
  
  <pre><code>-(void) changeAnimation:(NSString*)name forTime:(int) times {
   if(currentAnimation != @"attack")
   {
    id action = [CCAnimate actionWithAnimation:[self animationByName:name]];
    id repeatAction = [CCRepeat actionWithAction:action times:times];
    currentAction = [self runAction:repeatAction];
    lastANimation = currentAnimation;
    currentAnimation = name;
   }
   else if(currentAction.isDone)
   {
     //Here is where I would change the animation
     //but I commented the code for now
   }
  }
  </code></pre>
  
  <p>So when I run this and click on the button that changes the animation to "attack" (by calling [mysprite changeAnimation:@"attack" forTime:1];), I get a EXC_BAD_ACCESS error from the "currentAction.isDone" line, the next time the function is called (the joystick will call changeAnimation to try and change the animation to "run" or "idle", but I want the attack animation to finish first). Any thoughts on whyI get this? currentAction is declared in my class. </p>
  
  <p>Edit: there is nothing in the rest of the class that interacts with currentAction, beside a getter. Its declaration is in the .h (CCAction* surrentAction). Do I need to initialize it? I thought the returned value from runAction would be sufficient? ANyways, when I run the debugger, it is not nil, and assigned to the correct action.</p>
  
  <p>Thanks,</p>
  
  <p>Dave</p>
  
  <p>Edit:
  I ended up creating a sequence when "attacking" that calls a function that changes the currentAnimation, so i avoided the issue. Still no idea what was happening.
  Here's the answer if your interested:
  <a href="https://stackoverflow.com/questions/3273147/cocos2d-changing-animations-after-one-is-over">Other Post</a></p>