diff --git a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx
index b402870b0..4822ab843 100644
--- a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx
+++ b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx
@@ -594,11 +594,11 @@ class AnimationState {
if (last == null) {
setCurrent(trackIndex, entry, true);
queue.drain();
+ if (delay < 0) delay = 0;
} else {
last.next = entry;
entry.previous = last;
- if (delay <= 0)
- delay += last.getTrackComplete() - entry.mixDuration;
+ if (delay <= 0) delay = Math.max(delay + last.getTrackComplete() - entry.mixDuration, 0);
}
entry.delay = delay;
@@ -614,8 +614,7 @@ class AnimationState {
public function addEmptyAnimation(trackIndex:Int, mixDuration:Float, delay:Float):TrackEntry {
var entry:TrackEntry = addAnimation(trackIndex, emptyAnimation, false, delay);
- if (delay <= 0)
- entry.delay += entry.mixDuration - mixDuration;
+ if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
entry.mixDuration = mixDuration;
entry.trackEnd = mixDuration;
return entry;
diff --git a/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx b/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx
index 042111e73..cf5fbe4bc 100644
--- a/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx
+++ b/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx
@@ -56,7 +56,20 @@ class TrackEntry implements Poolable {
public var animationEnd:Float = 0;
public var animationLast:Float = 0;
public var nextAnimationLast:Float = 0;
- public var delay:Float = 0;
+
+ /** Seconds to postpone playing the animation. Must be >= 0. When this track entry is the current track entry,
+ * delay postpones incrementing the {@link #getTrackTime()}. When this track entry is queued,
+ * delay is the time from the start of the previous animation to when this track entry will become the current
+ * track entry (ie when the previous track entry {@link TrackEntry#getTrackTime()} >= this track entry's
+ * delay).
+ *
+ * {@link #getTimeScale()} affects the delay. + *
+ * When passing delay <= 0 to {@link AnimationState#addAnimation(int, Animation, boolean, float)} this
+ * delay is set using a mix duration from {@link AnimationStateData}. To change the {@link #getMixDuration()}
+ * afterward, use {@link #setMixDuration(float, float)} so this delay is adjusted. */
+ public var delay(default, set):Float = 0;
+
public var trackTime:Float = 0;
public var trackLast:Float = 0;
public var nextTrackLast:Float = 0;
@@ -64,7 +77,7 @@ class TrackEntry implements Poolable {
public var timeScale:Float = 0;
public var alpha:Float = 0;
public var mixTime:Float = 0;
- @:isVar public var mixDuration(get, set):Float = 0;
+ public var mixDuration:Float = 0;
public var interruptAlpha:Float = 0;
public var totalAlpha:Float = 0;
public var mixBlend:MixBlend = MixBlend.replace;
@@ -73,14 +86,9 @@ class TrackEntry implements Poolable {
public var timelinesRotation:Array