mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-01 13:19:08 +08:00
AnimationState, added draw order threshold.
This commit is contained in:
parent
c278cf77fb
commit
127c0fbbf5
@ -290,7 +290,7 @@ public class AnimationStateTest {
|
|||||||
expect(1, "complete 1", 1, 1.4f), //
|
expect(1, "complete 1", 1, 1.4f), //
|
||||||
expect(1, "end", 1, 1.5f) //
|
expect(1, "end", 1, 1.5f) //
|
||||||
);
|
);
|
||||||
state.setDefaultEventThreshold(0.5f);
|
state.setEventThreshold(0.5f);
|
||||||
state.setAnimation(0, "events1", false);
|
state.setAnimation(0, "events1", false);
|
||||||
state.addAnimation(0, "events2", false, 0.4f);
|
state.addAnimation(0, "events2", false, 0.4f);
|
||||||
run(0.1f, 1000);
|
run(0.1f, 1000);
|
||||||
@ -315,7 +315,7 @@ public class AnimationStateTest {
|
|||||||
expect(1, "complete 1", 1, 1.4f), //
|
expect(1, "complete 1", 1, 1.4f), //
|
||||||
expect(1, "end", 1, 1.5f) //
|
expect(1, "end", 1, 1.5f) //
|
||||||
);
|
);
|
||||||
state.setDefaultEventThreshold(1);
|
state.setEventThreshold(1);
|
||||||
state.setAnimation(0, "events1", false);
|
state.setAnimation(0, "events1", false);
|
||||||
state.addAnimation(0, "events2", false, 0.4f);
|
state.addAnimation(0, "events2", false, 0.4f);
|
||||||
run(0.1f, 1000);
|
run(0.1f, 1000);
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import com.badlogic.gdx.utils.IntArray;
|
|||||||
import com.badlogic.gdx.utils.Pool;
|
import com.badlogic.gdx.utils.Pool;
|
||||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||||
import com.esotericsoftware.spine.Animation.AttachmentTimeline;
|
import com.esotericsoftware.spine.Animation.AttachmentTimeline;
|
||||||
|
import com.esotericsoftware.spine.Animation.DrawOrderTimeline;
|
||||||
import com.esotericsoftware.spine.Animation.Timeline;
|
import com.esotericsoftware.spine.Animation.Timeline;
|
||||||
|
|
||||||
/** Stores state for an animation and automatically mixes between animations. */
|
/** Stores state for an animation and automatically mixes between animations. */
|
||||||
@ -46,7 +47,7 @@ public class AnimationState {
|
|||||||
private final EventQueue queue = new EventQueue();
|
private final EventQueue queue = new EventQueue();
|
||||||
final Array<AnimationStateListener> listeners = new Array();
|
final Array<AnimationStateListener> listeners = new Array();
|
||||||
private float timeScale = 1;
|
private float timeScale = 1;
|
||||||
private float defaultEventThreshold, defaultAttachmentThreshold;
|
private float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
||||||
|
|
||||||
final Pool<TrackEntry> trackEntryPool = new Pool() {
|
final Pool<TrackEntry> trackEntryPool = new Pool() {
|
||||||
protected Object newObject () {
|
protected Object newObject () {
|
||||||
@ -141,13 +142,15 @@ public class AnimationState {
|
|||||||
Array<Event> events = mix < previous.eventThreshold ? this.events : null;
|
Array<Event> events = mix < previous.eventThreshold ? this.events : null;
|
||||||
|
|
||||||
Array<Timeline> timelines = animation.timelines;
|
Array<Timeline> timelines = animation.timelines;
|
||||||
if (mix < previous.attachmentThreshold) {
|
boolean attachments = mix < previous.attachmentThreshold, drawOrder = mix < previous.drawOrderThreshold;
|
||||||
|
if (attachments && drawOrder) {
|
||||||
for (int i = 0, n = timelines.size; i < n; i++)
|
for (int i = 0, n = timelines.size; i < n; i++)
|
||||||
timelines.get(i).apply(skeleton, lastTime, time, events, alpha);
|
timelines.get(i).apply(skeleton, lastTime, time, events, alpha);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0, n = timelines.size; i < n; i++) {
|
for (int i = 0, n = timelines.size; i < n; i++) {
|
||||||
Timeline timeline = timelines.get(i);
|
Timeline timeline = timelines.get(i);
|
||||||
if (timeline instanceof AttachmentTimeline) continue;
|
if (!attachments && timeline instanceof AttachmentTimeline) continue;
|
||||||
|
if (!drawOrder && timeline instanceof DrawOrderTimeline) continue;
|
||||||
timeline.apply(skeleton, lastTime, time, events, alpha);
|
timeline.apply(skeleton, lastTime, time, events, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,8 +265,9 @@ public class AnimationState {
|
|||||||
entry.animation = animation;
|
entry.animation = animation;
|
||||||
entry.loop = loop;
|
entry.loop = loop;
|
||||||
entry.endTime = animation.getDuration();
|
entry.endTime = animation.getDuration();
|
||||||
entry.eventThreshold = defaultEventThreshold;
|
entry.eventThreshold = eventThreshold;
|
||||||
entry.attachmentThreshold = defaultAttachmentThreshold;
|
entry.attachmentThreshold = attachmentThreshold;
|
||||||
|
entry.drawOrderThreshold = drawOrderThreshold;
|
||||||
|
|
||||||
setCurrent(trackIndex, entry);
|
setCurrent(trackIndex, entry);
|
||||||
queue.drain();
|
queue.drain();
|
||||||
@ -284,8 +288,9 @@ public class AnimationState {
|
|||||||
entry.animation = animation;
|
entry.animation = animation;
|
||||||
entry.loop = loop;
|
entry.loop = loop;
|
||||||
entry.endTime = animation.getDuration();
|
entry.endTime = animation.getDuration();
|
||||||
entry.eventThreshold = defaultEventThreshold;
|
entry.eventThreshold = eventThreshold;
|
||||||
entry.attachmentThreshold = defaultAttachmentThreshold;
|
entry.attachmentThreshold = attachmentThreshold;
|
||||||
|
entry.drawOrderThreshold = drawOrderThreshold;
|
||||||
|
|
||||||
TrackEntry last = expandToIndex(trackIndex);
|
TrackEntry last = expandToIndex(trackIndex);
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
@ -339,20 +344,28 @@ public class AnimationState {
|
|||||||
this.timeScale = timeScale;
|
this.timeScale = timeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDefaultEventThreshold () {
|
public float getEventThreshold () {
|
||||||
return defaultEventThreshold;
|
return eventThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultEventThreshold (float defaultEventThreshold) {
|
public void setEventThreshold (float eventThreshold) {
|
||||||
this.defaultEventThreshold = defaultEventThreshold;
|
this.eventThreshold = eventThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDefaultAttachmentThreshold () {
|
public float getAttachmentThreshold () {
|
||||||
return defaultAttachmentThreshold;
|
return attachmentThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultAttachmentThreshold (float defaultAttachmentThreshold) {
|
public void setAttachmentThreshold (float attachmentThreshold) {
|
||||||
this.defaultAttachmentThreshold = defaultAttachmentThreshold;
|
this.attachmentThreshold = attachmentThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDrawOrderThreshold () {
|
||||||
|
return drawOrderThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrawOrderThreshold (float drawOrderThreshold) {
|
||||||
|
this.drawOrderThreshold = drawOrderThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimationStateData getData () {
|
public AnimationStateData getData () {
|
||||||
@ -385,7 +398,8 @@ public class AnimationState {
|
|||||||
TrackEntry next, previous;
|
TrackEntry next, previous;
|
||||||
Animation animation;
|
Animation animation;
|
||||||
boolean loop;
|
boolean loop;
|
||||||
float delay, time, lastTime = -1, endTime, timeScale = 1, eventThreshold, attachmentThreshold;
|
float delay, time, lastTime = -1, endTime, timeScale = 1;
|
||||||
|
float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
||||||
float mixTime, mixDuration;
|
float mixTime, mixDuration;
|
||||||
AnimationStateListener listener;
|
AnimationStateListener listener;
|
||||||
float alpha = 1;
|
float alpha = 1;
|
||||||
@ -488,6 +502,14 @@ public class AnimationState {
|
|||||||
this.attachmentThreshold = attachmentThreshold;
|
this.attachmentThreshold = attachmentThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getDrawOrderThreshold () {
|
||||||
|
return drawOrderThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrawOrderThreshold (float drawOrderThreshold) {
|
||||||
|
this.drawOrderThreshold = drawOrderThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
public TrackEntry getNext () {
|
public TrackEntry getNext () {
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user