mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Apply remaining time to next animation.
Previously one frame worth of delta time was lost. When the end of an animation is passed, one frame goes by so the animation has a chance to apply its final pose and fire any events on its last few frames. The second animation starts using the amount of time since the actual end of the first animation. #154
This commit is contained in:
parent
ec3db90e65
commit
2650e2679d
@ -64,21 +64,26 @@ public class AnimationState {
|
||||
TrackEntry current = tracks.get(i);
|
||||
if (current == null) continue;
|
||||
|
||||
TrackEntry next = current.next;
|
||||
if (next != null) {
|
||||
float nextTime = current.lastTime - next.delay;
|
||||
if (nextTime >= 0) {
|
||||
next.time = nextTime;
|
||||
setCurrent(i, next);
|
||||
current = next;
|
||||
}
|
||||
} else if (!current.loop && current.lastTime >= current.endTime) {
|
||||
// End non-looping animation when it reaches its end time and there is no next entry.
|
||||
clearTrack(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
current.time += delta * current.timeScale;
|
||||
if (current.previous != null) {
|
||||
float previousDelta = delta * current.previous.timeScale;
|
||||
current.previous.time += previousDelta;
|
||||
current.mixTime += previousDelta;
|
||||
}
|
||||
|
||||
TrackEntry next = current.next;
|
||||
if (next != null) {
|
||||
next.time = current.lastTime - next.delay;
|
||||
if (next.time >= 0) setCurrent(i, next);
|
||||
} else {
|
||||
// End non-looping animation when it reaches its end time and there is no next entry.
|
||||
if (!current.loop && current.lastTime >= current.endTime) clearTrack(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user