Best Practice to manage Spine SkeletonAnimation

Best Practice to manage Spine SkeletonAnimation
0.0 0


Hi, I’m working with spine runtime and cocos2d-x 3.14.1

I have some SkeletonAnimation that run animation and at the CompleteListener I would like to remove it.

With Cocos2d-x 2.2.6 (and old spine runtime) I use this code with success

  SkeletonAnim * anim = SkeletonAnimation::createWithJsonFile(skeletonDataFile, atlasFile, 1.0);

  spTrackEntry * entry = anim->setAnimation(0, animName, false);
  anim->setTrackCompleteListener(entry, [anim] (int trackIndex, int loopCount)

With Cocos2d-x 3.14.1 this code raise an exception in SkeletonAnimation::update(float deltaTime).
Dispose of the instance of SkeletonAnimation arrived when update are running yet, so, I think, this cause the error.

Is there some sample or best practice to delete SkeletonAnimation at the end of the animation?

thank you



make sure that cocos2d-x runtime version match your exported spine version :slight_smile: maybe u trying to use old spine animation in new runtime.


Thank you for reply, I use spine 3.4.02, that match the version of cocos2d-x that I have (3.14.1 downloaded in december 2016)

I don’t think is about match of spine and runtime.
Maybe I use a wrong way to delete SkeletonAnimation

Do you know a way to do that?
Do you have ever used code like that write above?


I use Spine runtine 2.5.

This bug should be fixed in versions after 2.3, but it still happens.


Someone can help me?

Thank you


Here the solution