diff --git a/spine-ts/spine-core/src/Animation.ts b/spine-ts/spine-core/src/Animation.ts index 4b60cf9e3..9fcdeaf4f 100644 --- a/spine-ts/spine-core/src/Animation.ts +++ b/spine-ts/spine-core/src/Animation.ts @@ -1789,7 +1789,8 @@ export class EventTimeline extends Timeline { /** Changes a skeleton's {@link Skeleton#drawOrder}. */ export class DrawOrderTimeline extends Timeline { - static propertyIds = [`${Property.drawOrder}`]; + static readonly propertyID = `${Property.drawOrder}`; + static propertyIds = [DrawOrderTimeline.propertyID]; /** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */ private readonly drawOrders: Array | null>; @@ -1846,7 +1847,7 @@ export class DrawOrderFolderTimeline extends Timeline { /** @param slots {@link Skeleton#slots} indices controlled by this timeline, in setup order. * @param slotCount The maximum number of slots in the skeleton. */ constructor (frameCount: number, slots: number[], slotCount: number) { - super(frameCount, ...DrawOrderTimeline.propertyIds); + super(frameCount, ...DrawOrderFolderTimeline.propertyIds(slots)); this.slots = slots; this.drawOrders = new Array(frameCount); this.inFolder = new Array(slotCount); @@ -1854,6 +1855,14 @@ export class DrawOrderFolderTimeline extends Timeline { this.inFolder[i] = true; } + private static propertyIds (slots: number[]): string[] { + const n = slots.length; + const ids = new Array(n); + for (let i = 0; i < n; i++) + ids[i] = `d${slots[i]}`; + return ids; + } + getFrameCount (): number { return this.frames.length; } diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index 031949a3f..9d80a8009 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -777,8 +777,12 @@ export class AnimationState { const propertyIDs = this.propertyIDs; if (to?.holdPrevious) { - for (let i = 0; i < timelinesCount; i++) - timelineMode[i] = propertyIDs.addAll(timelines[i].getPropertyIds()) ? HOLD_FIRST : HOLD_SUBSEQUENT; + for (let i = 0; i < timelinesCount; i++) { + let first = propertyIDs.addAll(timelines[i].getPropertyIds()); + if (first && timelines[i] instanceof DrawOrderFolderTimeline && propertyIDs.contains(DrawOrderTimeline.propertyID)) + first = false; // DrawOrderTimeline changed. + timelineMode[i] = first ? HOLD_FIRST : HOLD_SUBSEQUENT; + } return; } @@ -788,6 +792,8 @@ export class AnimationState { const ids = timeline.getPropertyIds(); if (!propertyIDs.addAll(ids)) timelineMode[i] = SUBSEQUENT; + else if (timeline instanceof DrawOrderFolderTimeline && propertyIDs.contains(DrawOrderTimeline.propertyID)) + timelineMode[i] = SUBSEQUENT; // DrawOrderTimeline changed. else if (!to || timeline instanceof AttachmentTimeline || timeline instanceof DrawOrderTimeline || timeline instanceof DrawOrderFolderTimeline || timeline instanceof EventTimeline || !to.animation!.hasTimeline(ids)) {