浏览代码

[ts] Port of commit 8d058fb: Improved AnimationState behavior when paused. See #2705.

Davide Tantillo 9 月之前
父节点
当前提交
7e92141215
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      spine-ts/spine-core/src/AnimationState.ts

+ 11 - 9
spine-ts/spine-core/src/AnimationState.ts

@@ -138,16 +138,18 @@ export class AnimationState {
 		from.animationLast = from.nextAnimationLast;
 		from.trackLast = from.nextTrackLast;
 
-		// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
-		if (to.mixTime > 0 && to.mixTime >= to.mixDuration) {
-			// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
-			if (from.totalAlpha == 0 || to.mixDuration == 0) {
-				to.mixingFrom = from.mixingFrom;
-				if (from.mixingFrom) from.mixingFrom.mixingTo = to;
-				to.interruptAlpha = from.interruptAlpha;
-				this.queue.end(from);
+		if (to.nextTrackLast != -1) { // The from entry was applied at least once.
+			const 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 != null) from.mixingFrom.mixingTo = to;
+					to.interruptAlpha = from.interruptAlpha;
+					this.queue.end(from);
+				}
+				return finished;
 			}
-			return finished;
 		}
 
 		from.trackTime += delta * from.timeScale;