diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index dd3b57c08..1ae154961 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -806,6 +806,20 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) { return finished; } + if (to->_nextTrackLast != -1) { // The from entry was applied at least once. + bool discard = to->_mixTime == 0 && from->_mixTime == 0; // Discard the from entry when neither have advanced yet. + if (to->_mixTime >= to->_mixDuration || discard) { + // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded. + if (from->_totalAlpha == 0 || to->_mixDuration == 0 || discard) { + to->_mixingFrom = from->_mixingFrom; + if (from->_mixingFrom) from->_mixingFrom->_mixingTo = to; + to->_interruptAlpha = from->_interruptAlpha; + _queue->end(from); + } + return finished; + } + } + from->_trackTime += delta * from->_timeScale; to->_mixTime += delta; diff --git a/spine-glfw/example/main.cpp b/spine-glfw/example/main.cpp index cb1703b9c..018eefa44 100644 --- a/spine-glfw/example/main.cpp +++ b/spine-glfw/example/main.cpp @@ -52,8 +52,10 @@ int main() { // Create an AnimationState to drive animations on the skeleton. Set the "portal" animation // on track with index 0. AnimationStateData animationStateData(skeletonData); + animationStateData.setDefaultMix(0.2f); AnimationState animationState(&animationStateData); animationState.setAnimation(0, "portal", true); + animationState.addAnimation(0, "run", true, 0); // Create the renderer and set the viewport size to match the window size. This sets up a // pixel perfect orthogonal projection for 2D rendering.