diff --git a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx index 8445c8ed9..9c076c551 100644 --- a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx +++ b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx @@ -283,7 +283,7 @@ class AnimationState { for (ii in 0...timelineCount) { var timeline:Timeline = timelines[ii]; - var timelineBlend:MixBlend = timelineMode[ii] == SUBSEQUENT ? current.mixBlendblend : MixBlend.setup; + var timelineBlend:MixBlend = timelineMode[ii] == SUBSEQUENT ? current.mixBlend : MixBlend.setup; if (!shortestRotation && Std.isOfType(timeline, RotateTimeline)) { this.applyRotateTimeline(cast(timeline, RotateTimeline), skeleton, applyTime, alpha, timelineBlend, current.timelinesRotation, ii << 1, firstFrame); @@ -875,7 +875,10 @@ class AnimationState { if (to != null && to.holdPrevious) { for (i in 0...timelinesCount) { - timelineMode[i] = propertyIDs.addAll(timelines[i].propertyIds) ? HOLD_FIRST : HOLD_SUBSEQUENT; + var first = propertyIDs.addAll(timelines[i].propertyIds); + if (first && Std.isOfType(timelines[i], DrawOrderFolderTimeline) && propertyIDs.contains(DrawOrderTimeline.propertyID)) + first = false; // DrawOrderTimeline changed. + timelineMode[i] = first ? HOLD_FIRST : HOLD_SUBSEQUENT; } return; } @@ -885,9 +888,11 @@ class AnimationState { continueOuter = false; var timeline:Timeline = timelines[i]; var ids:Array = timeline.propertyIds; - if (!propertyIDs.addAll(ids)) { + if (!propertyIDs.addAll(ids)) timelineMode[i] = SUBSEQUENT; - } else if (to == null + else if (Std.isOfType(timeline, DrawOrderFolderTimeline) && propertyIDs.contains(DrawOrderTimeline.propertyID)) + timelineMode[i] = SUBSEQUENT; // DrawOrderTimeline changed. + else if (to == null || Std.isOfType(timeline, AttachmentTimeline) || Std.isOfType(timeline, DrawOrderTimeline) || Std.isOfType(timeline, DrawOrderFolderTimeline) diff --git a/spine-haxe/spine-haxe/spine/animation/DrawOrderFolderTimeline.hx b/spine-haxe/spine-haxe/spine/animation/DrawOrderFolderTimeline.hx index f71546f03..ef1c8eb74 100644 --- a/spine-haxe/spine-haxe/spine/animation/DrawOrderFolderTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/DrawOrderFolderTimeline.hx @@ -42,7 +42,7 @@ class DrawOrderFolderTimeline extends Timeline { /** @param slots spine.Skeleton.slots indices controlled by this timeline, in setup order. * @param slotCount The maximum number of slots in the skeleton. */ public function new(frameCount:Int, slots:Array, slotCount:Int) { - super(frameCount, Property.drawOrder); + super(frameCount, ...DrawOrderFolderTimeline.getPropertyIds(slots)); this.slots = slots; drawOrders = new Array>(); drawOrders.resize(frameCount); @@ -54,6 +54,14 @@ class DrawOrderFolderTimeline extends Timeline { inFolder[i] = true; } + private static function getPropertyIds(slots:Array):Array { + var n = slots.length; + var ids = new Array(); + for (i in 0...n) + ids[i] = "d" + slots[i]; + return ids; + } + public var frameCount(get, never):Int; private function get_frameCount():Int { @@ -82,9 +90,11 @@ class DrawOrderFolderTimeline extends Timeline { public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection, appliedPose:Bool) { if (direction == MixDirection.mixOut) { - if (blend == MixBlend.setup) setupApply(skeleton); + if (blend == MixBlend.setup) + setupApply(skeleton); } else if (time < frames[0]) { - if (blend == MixBlend.setup || blend == MixBlend.first) setupApply(skeleton); + if (blend == MixBlend.setup || blend == MixBlend.first) + setupApply(skeleton); } else { var order = drawOrders[Timeline.search1(frames, time)]; if (order == null) @@ -103,7 +113,8 @@ class DrawOrderFolderTimeline extends Timeline { if (inFolder[drawOrder[i].data.index]) { drawOrder[i] = allSlots[slots[found]]; found++; - if (found == done) break; + if (found == done) + break; } i++; } @@ -118,7 +129,8 @@ class DrawOrderFolderTimeline extends Timeline { if (inFolder[drawOrder[i].data.index]) { drawOrder[i] = allSlots[slots[order[found]]]; found++; - if (found == done) break; + if (found == done) + break; } i++; } diff --git a/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx b/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx index dfa335d1e..f53382eb6 100644 --- a/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx @@ -35,6 +35,8 @@ import spine.Slot; /** Changes a skeleton's Skeleton#drawOrder. */ class DrawOrderTimeline extends Timeline { + public static final propertyID = Property.drawOrder; + /** The draw order for each frame. See setFrame(). */ public var drawOrders:Array>;