• Editor
  • Stop animation and set initial frame.

Hi!

I use C api in my cocos2d-x application and this is the question: how to stop current animation and set initial frame to a skeleton immediately? Maybe it's a popular question, but I didn't find something related.

BTW, do you plan to provide complete C++ API?

Related Discussions
...

You can stop the animation using either of these:
AnimationState_clearAnimation(skeletonNode->state);
AnimationState_setAnimation(skeletonNode->state, 0, false);

I'm not sure what you mean by "set initial frame to a skeleton immediately"?

No, the C API will be used for C, C++, and ObjC languages.

Thanks, clearAnimation works, but I want a little different behavior:

"set initial frame to a skeleton immediately"?

For example, Player skeleton plays "walk" animation if I press a button, but when button is released, I want not only to stop animation, but also set the skeleton sprite in initial position, like zero frame. Is it possible?

Ah, sure. You can set the skeleton back to the bind pose:

Skeleton_setBonesToBindPose(skeletonNode->skeleton);
Skeleton_setSlotsToBindPose(skeletonNode->skeleton);
Skeleton_setToBindPose(skeletonNode->skeleton); // Does both bones and slots.

Thanks! It works.

9 mois plus tard

Hey Nate and Spime experts:

Is there a way to transition (similar to 'mix') into the bind pose?

In AS3 I had to do this in the touch event handler:

	skeletonAnimation.state.clearTracks();
	skeleton.setToSetupPose();

But it's very abrupt. We may need to add a 0.2s animation called 'stop' in the GUI and mix it with all the animations we have.

We are trying to build a flow so wanted to be sure of the proper way of doing things.

Thanks

I think using an animation that keys the bind pose is a reasonable way to mix an animation to the bind pose. However, you may want to use a looping idle animation to give your skeleton some life even when not otherwise animated.