mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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;
|
return slotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The attachment for which the {@link SlotPose#getSequenceIndex()} will be set.
|
||||||
|
* <p>
|
||||||
|
* See {@link VertexAttachment#getTimelineAttachment()}. */
|
||||||
public Attachment getAttachment () {
|
public Attachment getAttachment () {
|
||||||
return (Attachment)attachment;
|
return (Attachment)attachment;
|
||||||
}
|
}
|
||||||
@ -1753,10 +1756,7 @@ public class Animation {
|
|||||||
SlotPose pose = appliedPose ? slot.applied : slot.pose;
|
SlotPose pose = appliedPose ? slot.applied : slot.pose;
|
||||||
|
|
||||||
Attachment slotAttachment = pose.attachment;
|
Attachment slotAttachment = pose.attachment;
|
||||||
if (slotAttachment != attachment) {
|
if (!(slotAttachment instanceof HasSequence hasSequence) || slotAttachment.getTimelineAttachment() != attachment) return;
|
||||||
if (!(slotAttachment instanceof VertexAttachment vertexAttachment)
|
|
||||||
|| vertexAttachment.getTimelineAttachment() != attachment) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (direction == out) {
|
if (direction == out) {
|
||||||
if (blend == setup) pose.setSequenceIndex(-1);
|
if (blend == setup) pose.setSequenceIndex(-1);
|
||||||
@ -1774,7 +1774,7 @@ public class Animation {
|
|||||||
int modeAndIndex = (int)frames[i + MODE];
|
int modeAndIndex = (int)frames[i + MODE];
|
||||||
float delay = frames[i + DELAY];
|
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];
|
SequenceMode mode = SequenceMode.values[modeAndIndex & 0xf];
|
||||||
if (mode != SequenceMode.hold) {
|
if (mode != SequenceMode.hold) {
|
||||||
index += (time - before) / delay + 0.0001f;
|
index += (time - before) / delay + 0.0001f;
|
||||||
|
|||||||
@ -29,18 +29,34 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine.attachments;
|
package com.esotericsoftware.spine.attachments;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Null;
|
||||||
|
|
||||||
/** The base class for all attachments. */
|
/** The base class for all attachments. */
|
||||||
abstract public class Attachment {
|
abstract public class Attachment {
|
||||||
final String name;
|
final String name;
|
||||||
|
@Null Attachment timelineAttachment;
|
||||||
|
|
||||||
public Attachment (String name) {
|
public Attachment (String name) {
|
||||||
if (name == null) throw new IllegalArgumentException("name cannot be null.");
|
if (name == null) throw new IllegalArgumentException("name cannot be null.");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
timelineAttachment = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy constructor. */
|
/** Copy constructor. */
|
||||||
protected Attachment (Attachment other) {
|
protected Attachment (Attachment other) {
|
||||||
name = other.name;
|
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. */
|
/** The attachment's name. */
|
||||||
|
|||||||
@ -46,7 +46,6 @@ abstract public class VertexAttachment extends Attachment {
|
|||||||
static private int nextID;
|
static private int nextID;
|
||||||
|
|
||||||
private final int id = nextID();
|
private final int id = nextID();
|
||||||
@Null Attachment timelineAttachment = this;
|
|
||||||
@Null int[] bones;
|
@Null int[] bones;
|
||||||
float[] vertices;
|
float[] vertices;
|
||||||
int worldVerticesLength;
|
int worldVerticesLength;
|
||||||
@ -58,7 +57,6 @@ abstract public class VertexAttachment extends Attachment {
|
|||||||
/** Copy constructor. */
|
/** Copy constructor. */
|
||||||
public VertexAttachment (VertexAttachment other) {
|
public VertexAttachment (VertexAttachment other) {
|
||||||
super(other);
|
super(other);
|
||||||
timelineAttachment = other.timelineAttachment;
|
|
||||||
|
|
||||||
if (other.bones != null) {
|
if (other.bones != null) {
|
||||||
bones = new int[other.bones.length];
|
bones = new int[other.bones.length];
|
||||||
@ -177,17 +175,6 @@ abstract public class VertexAttachment extends Attachment {
|
|||||||
this.worldVerticesLength = worldVerticesLength;
|
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. */
|
/** Returns a unique ID for this attachment. */
|
||||||
public int getId () {
|
public int getId () {
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user