Best Practice to manage Spine SkeletonAnimation

Best Practice to manage Spine SkeletonAnimation
0.0 0

#1

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);
  this->addChild(anim);

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

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
Don


#2

Hi,

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.


#3

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?


#4

I use Spine runtine 2.5.

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


#5

Someone can help me?

Thank you


#6

Here the solution