I try to add jump animation to my game buy my app crashes for some reason. I get EXC_BAD_EXCESS.
This is my animation code:
-(void)jump{
NSMutableArray *jump = [NSMutableArray array];
for(int i = 1; i<=5; i++){
[jump addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"frame%d.png",i]]];
NSLog(@"Sprite: frame%d.png",i);
}
NSMutableArray *jumpReverse = [NSMutableArray array];
for(int i = 5; i>=1; i--){
[jump addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"frame%d.png",i]]];
NSLog(@"Sprite Back: frame%d.png",i);
}
CCAnimation *jumpAnimation = [CCAnimation animationWithFrames:jump delay:0.1];
CCAnimation *jumpReverseAnimation = [CCAnimation animationWithFrames:jumpReverse delay:0.1];
id jump1 = [CCAnimate actionWithDuration:.5f animation:jumpAnimation restoreOriginalFrame:NO];
id jump2 = [CCAnimate actionWithAnimation:jumpReverseAnimation restoreOriginalFrame:NO];
[bodySprite runAction:[CCSequence actions:jump1,jump2, nil]];
}
What am I doing wrong?
Thanks!