• Runtimes
  • Question about interpolation

Related Discussions
...

I am trying to interpolate two animations a1 and a2. I play a1 on the skeleton with [SkeletonAnimationObject setAnimationForTrack:0 name:a1 loop:NO]. After the animation a1 has finished I do [SkeletonAnimationObject setMixFrom:a1 to:a2 duration:0.5] and [SkeletonAnimation setAnimationForTrack:0 name:a2 loop:NO]. The result is that when i set the second animation the skeleton snaps to the starting frame of the second animation instead of interpolating from the end position of the first animation. What is the mistake i am making here?

To blend from one animation to the next, the runtime needs to apply animation A, then mix the pose from animation B on top of the pose from A. If A is no longer being applied and you only tell B to play, then when B is applied, the pose from A is overwritten.

You don't need to let A end before setting the second. Instead, for spine-cocos2d, you can do setAnimationForTrack then addAnimationForTrack.

If you really want to wait for animation A to finish, then do:

spTrackEntry* trackEntry = [skeletonAnimation setAnimationForTrack:0 name:A2 loop:NO];
trackEntry->endTime = 99999;

The endTime is set to the animation duration (in seconds) by default. When the animation reaches the end time, it is removed from the track (or loops if it is looping). This is why by the time you play B, A is no longer being applied and you get no mixing. Setting A's endTime to something high means A is still applied until you call setAnimationForTrack to play B, so then you get crossfading.

25 jours plus tard

Worked. Thank you so much!


I am seeing some graphical glitches due to interpolation. For instance the character's arms would become flat as a paper during the start of the next animation or like the face of the character will be distorted to the entire screen. These issues dont occur when i turn off mixing. Any ideas? Thanks!

you're flipping body parts using negative scale?