Issue when running an animation twice from the Cocosbuilder animation delegate


#1

Hello!

First, thanks for the great job… Cocos2d-x is awesome and I really enjoy using it.

I’m running cocos2d-x 2.0.3 with cocosbuilder 2.1 and I use the cocosbuilder animation delegate (CCBAnimationManagerDelegate::completedAnimationSequenceNamed) to get notified when an animation has completed and take actions like firing another cocosbuilder animation.
It runs fine the first time an animation is run from the delegate but crashes the second time it has completed.

The application crashes the second times CCBAnimationManager::sequenceCompleted is called. I worked around the issue commenting out the “mRunngingSequence = NULL;” line.

Is this a bug or am I not supposed to run animations from the CCBAnimationManagerDelegate::completedAnimationSequenceNamed methode!?

Thanks in advance for your help. :slight_smile:

void CCBAnimationManager::sequenceCompleted()
{
    if (mDelegate)
    {
        // mRunningSequence->getName() will crash when running an animation twice from the delegate
        mDelegate->completedAnimationSequenceNamed(mRunningSequence->getName()); 
    }

    int nextSeqId = mRunningSequence->getChainedSequenceId();

    /// Commenting out the following line avoid the application to crash when running animations from CCBAnimationManagerDelegate::completedAnimationSequenceNamed.
    /// mRunningSequence = NULL;

    if (nextSeqId != -1)
    {
        runAnimations(nextSeqId, 0);
    }
}