Sorry if this is is an obvious problem...
I have three possible states -- square, circle, and triangle -- for my player character in the game, and six animations to morph between them. The CCAnimations themselves are fine. I'm able to run the CCAnimate action on them and my sprite to make them animate exactly the way I want to using this code in the init method:
[polyGuy runAction:[CCAnimate actionWithAnimation:transformCircleToSquareAnim restoreOriginalFrame:NO]];
I have three buttons in the form of CCMenuItems in my scene, one for each shape, which each call a method which checks the current shape and animates accordingly, e.g.:
- (void)squareTransform {
if (currentShape == 1) {
[polyGuy runAction:[CCAnimate actionWithAnimation:transformCircleToSquareAnim restoreOriginalFrame:NO]];
} else if (currentShape == 2) {
[polyGuy runAction:[CCAnimate actionWithAnimation:transformTriangleToSquareAnim restoreOriginalFrame:NO]];
}
currentShape = 0;
}
(0 is a square, 1 is a circle, and 2 is a triangle)
However this does not work! It instead shows an EXC_BAD_ACCESS error in the debugger at the point when the runAction: is being called. I know this is is quite a common error, and so I and my lack of knowledge have tried to find a cure for the past two hours to no avail.
Please help!