浏览代码

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
NathanSweet 9 年之前
父节点
当前提交
2650e2679d
共有 1 个文件被更改,包括 14 次插入9 次删除
  1. 14 9
      spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java

+ 14 - 9
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java

@@ -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);
-			}
 		}
 	}