mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 06:29:02 +08:00
[libgdx] Improved SequenceTimeline for RegionAttachment copies, moved timelineAttachment to Attachment.
This commit is contained in:
parent
18740aa2fd
commit
1cef1397c0
@ -1731,6 +1731,9 @@ public class Animation {
|
||||
return slotIndex;
|
||||
}
|
||||
|
||||
/** The attachment for which the {@link SlotPose#getSequenceIndex()} will be set.
|
||||
* <p>
|
||||
* 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;
|
||||
|
||||
@ -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. */
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user