Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to run multiple ccAnimation in one ccSprite
    text
    copied!<p>I have one character sprite and i have to run multiple ccAnimation on it like run animation and jump animation. For this i have created spritesheet and assign it the frames. here is my code:</p> <pre><code> [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"ch_run_slow.plist"]; spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"ch_run_slow.png"]; [self addChild:spriteSheet]; _character = [CCSprite spriteWithSpriteFrameName:@"Ch_run_slow_12.png"]; _character.tag=1; [spriteSheet addChild:_character]; </code></pre> <p>and my animation functions are: </p> <pre><code>-(void) characterSlowRun { NSMutableArray *runSlowAnimFrames = [NSMutableArray array]; for (int i=1; i&lt;=12; i++) { [runSlowAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"Ch_run_slow_%d.png",i]]]; } CCAnimation *runSlow = [CCAnimation animationWithSpriteFrames:runSlowAnimFrames delay:0.1f]; runSlowAction=[CCAnimate actionWithAnimation:runSlow]; runSlowAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:runSlow]]; [_character runAction:runSlowAction]; } </code></pre> <p>and Jump Action method is:</p> <pre><code>-(void) characterJumpSmall { [[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFramesFromFile:@"ch_run_slow.plist"]; [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"ch_jump_small.plist"]; spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"ch_jump_small.png"]; NSMutableArray *jumpSmallAnimFrames = [NSMutableArray array]; for (int i=1; i&lt;=13; i++) { [jumpSmallAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"Ch_jump_small_%d.png",i]]]; } CCAnimation *jumpSmall = [CCAnimation animationWithSpriteFrames:jumpSmallAnimFrames delay:0.1f]; jumpSmallAction=[CCAnimate actionWithAnimation:jumpSmall]; [_character runAction:jumpSmallAction]; } </code></pre> <p>on init i call [self characterSlowRun]; and on ccTouchesEnded i use [_character stopAction:runSlowAction]; [self characterJumpSmall]; initially runSlow action works fine bt when tap on screen it crashes. jump action not working. what i do? please help me</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload