0

This is the code to show sprite sheet animation if something happens in the game, animation works perfect but it is not stopping after the animation frames sequence complete, i had done so many things to stop the animation, but nothing is giving me solution, here is my code

if(m_bEffectChangeColor){

`

        m_gamecoinffect = [CCSprite spriteWithSpriteFrameName:@"powerup0001"];
          [self addChild:m_gamecoinffect z:3];



        CCAnimate *coineffect = [CCAnimate actionWithSpriteSequence:@"powerup%04d" numFrames:30 delay:0.1f restoreOriginalFrame:NO];
        [m_gamecoinffect runAction:[CCRepeatForever actionWithAction:coineffect]];

        m_gamecoinffect.position = ptEffectPos;

        CCCallBlock *block = [CCCallBlock actionWithBlock:^{
            //[m_gamecoinffect stopAllActions];
            [self removeChild:m_gamecoinffect cleanup:YES];

        }];
        CCDelayTime *time = [CCDelayTime actionWithDuration:1];
        [m_gamecoinffect runAction:[CCSequence actions:time, block, nil]];

`

Above code i tried to add timer and everything i know, but nothing is working,,, i would like to stop animation and remove those sprite from the layer.

Thanks in advance.

1 Answer 1

2

The animation does not stop because the CCRepeatForever is the action which animates forever means continuously. Change below line:

[m_gamecoinffect runAction:[CCRepeatForever actionWithAction:coineffect]];

With

[m_gamecoinffect runAction:coineffect];
1
  • ok thanks for your replay,, let me check if its work or not.. Thank you once again
    – ICoder
    Jan 11, 2017 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.