diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java index 2cffd1ffc..cebd1e1ad 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java @@ -1731,6 +1731,9 @@ public class Animation { return slotIndex; } + /** The attachment for which the {@link SlotPose#getSequenceIndex()} will be set. + *
+ * See {@link VertexAttachment#getTimelineAttachment()}. */ public Attachment getAttachment () { return (Attachment)attachment; } @@ -1753,10 +1756,7 @@ public class Animation { SlotPose pose = appliedPose ? slot.applied : slot.pose; Attachment slotAttachment = pose.attachment; - if (slotAttachment != attachment) { - if (!(slotAttachment instanceof VertexAttachment vertexAttachment) - || vertexAttachment.getTimelineAttachment() != attachment) return; - } + if (!(slotAttachment instanceof HasSequence hasSequence) || slotAttachment.getTimelineAttachment() != attachment) return; if (direction == out) { if (blend == setup) pose.setSequenceIndex(-1); @@ -1774,7 +1774,7 @@ public class Animation { int modeAndIndex = (int)frames[i + MODE]; float delay = frames[i + DELAY]; - int index = modeAndIndex >> 4, count = (((HasSequence)slotAttachment).getSequence()).getRegions().length; + int index = modeAndIndex >> 4, count = hasSequence.getSequence().getRegions().length; SequenceMode mode = SequenceMode.values[modeAndIndex & 0xf]; if (mode != SequenceMode.hold) { index += (time - before) / delay + 0.0001f; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java index 5b448094c..4f0f464a4 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/Attachment.java @@ -29,18 +29,34 @@ package com.esotericsoftware.spine.attachments; +import com.badlogic.gdx.utils.Null; + /** The base class for all attachments. */ abstract public class Attachment { final String name; + @Null Attachment timelineAttachment; public Attachment (String name) { if (name == null) throw new IllegalArgumentException("name cannot be null."); this.name = name; + timelineAttachment = this; } /** Copy constructor. */ protected Attachment (Attachment other) { name = other.name; + timelineAttachment = other.timelineAttachment; + } + + /** Timelines for the timeline attachment are also applied to this attachment. + * @return May be null if no attachment-specific timelines should be applied. */ + public @Null Attachment getTimelineAttachment () { + return timelineAttachment; + } + + /** @param timelineAttachment May be null if no attachment-specific timelines should be applied. */ + public void setTimelineAttachment (@Null Attachment timelineAttachment) { + this.timelineAttachment = timelineAttachment; } /** The attachment's name. */ diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java index f18c0a59c..451a1c97a 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java @@ -46,7 +46,6 @@ abstract public class VertexAttachment extends Attachment { static private int nextID; private final int id = nextID(); - @Null Attachment timelineAttachment = this; @Null int[] bones; float[] vertices; int worldVerticesLength; @@ -58,7 +57,6 @@ abstract public class VertexAttachment extends Attachment { /** Copy constructor. */ public VertexAttachment (VertexAttachment other) { super(other); - timelineAttachment = other.timelineAttachment; if (other.bones != null) { bones = new int[other.bones.length]; @@ -177,17 +175,6 @@ abstract public class VertexAttachment extends Attachment { this.worldVerticesLength = worldVerticesLength; } - /** Timelines for the timeline attachment are also applied to this attachment. - * @return May be null if no attachment-specific timelines should be applied. */ - public @Null Attachment getTimelineAttachment () { - return timelineAttachment; - } - - /** @param timelineAttachment May be null if no attachment-specific timelines should be applied. */ - public void setTimelineAttachment (Attachment timelineAttachment) { - this.timelineAttachment = timelineAttachment; - } - /** Returns a unique ID for this attachment. */ public int getId () { return id;