Spine Rendering Issue

Hi all,

I set the node’s active to true and then setAnimation of its Spine component, and I expect to see, that the first frame of rendering is the first frame of that exact animation, but the result is, that I see the skeleton bones in their default position for one frame and only after that the animation starts to be rendered. Is there any way to fix that glitch? Or why setAnimation function called after .node.active = true is not affecting the rendering immediately?

@jare

The issue here is that when you start playing the animation, it doesn’t actually call update on the animation until the next cocos2d update call. I had this happen in my game, so to get around this, I needed to call update on the animation right after setting the animation.

For example (this is in C++, so you’ll have to adapt it):

skeletonAnimation->setAnimation(0, “MyAnimation”, true);
skeletonAnimation->update(0); // Force an update to make sure it renders it in the current frame

1 Like

Yes , this works and is a nice workaround, but I think better to put this line of code inside the engine. I wonder why its not implemented like that.

If by engine you mean Cocos2d-x, it’s not their issue or responsibility. It’s in the code that is provided by Esoteric Software, who created the runtime for Cocos2d-x.

It may not be a good idea to change the runtime behavior to force the update call inside the setAnimation(), since you may want to call other methods on the skeletal animation before the update occurs. The current behavior of the code may actually be correct, and it lets the developer decide if and when there is a need to call update() after the setAnimation().

I will ask Owen to read this thread. He is currently on holiday and can get back to you tomorrow.

Does this problem also apply to normal animations (non-spine-based)? I’m getting a very similar behavior on my menu animations.

While the specific issue the OP mentioned was related to how to use Spine, the reason may be the same for your case. A debugger is your friend in this case, and you can check if it is rendering what it needs to in a given update cycle. If you’re using Windows with an nVidia graphics card, then try using the NVIDIA Nsight Graphics app to see exactly what is happening frame by frame.