[as3] Ported latest AnimationState changes

This commit is contained in:
badlogic 2016-11-28 16:37:06 +01:00
parent c604d93a5c
commit 14d872b092
4 changed files with 7 additions and 5 deletions

View File

@ -89,7 +89,7 @@ public class AnimationState {
next.delay = 0; next.delay = 0;
next.trackTime = nextTime + delta * next.timeScale; next.trackTime = nextTime + delta * next.timeScale;
current.trackTime += currentDelta; current.trackTime += currentDelta;
setCurrent(i, next); setCurrent(i, next, true);
while (next.mixingFrom != null) { while (next.mixingFrom != null) {
next.mixTime += currentDelta; next.mixTime += currentDelta;
next = next.mixingFrom; next = next.mixingFrom;
@ -355,12 +355,12 @@ public class AnimationState {
} }
private function setCurrent (index:int, current:TrackEntry):void { private function setCurrent (index:int, current:TrackEntry, interrupt:Boolean):void {
var from:TrackEntry = expandToIndex(index); var from:TrackEntry = expandToIndex(index);
tracks[index] = current; tracks[index] = current;
if (from != null) { if (from != null) {
queue.interrupt(from); if (interrupt) queue.interrupt(from);
current.mixingFrom = from; current.mixingFrom = from;
current.mixTime = 0; current.mixTime = 0;
@ -381,6 +381,7 @@ public class AnimationState {
public function setAnimation (trackIndex:int, animation:Animation, loop:Boolean):TrackEntry { public function setAnimation (trackIndex:int, animation:Animation, loop:Boolean):TrackEntry {
if (animation == null) throw new ArgumentError("animation cannot be null."); if (animation == null) throw new ArgumentError("animation cannot be null.");
var interrupt:Boolean = true;
var current:TrackEntry = expandToIndex(trackIndex); var current:TrackEntry = expandToIndex(trackIndex);
if (current != null) { if (current != null) {
if (current.nextTrackLast == -1) { if (current.nextTrackLast == -1) {
@ -390,11 +391,12 @@ public class AnimationState {
queue.end(current); queue.end(current);
disposeNext(current); disposeNext(current);
current = current.mixingFrom; current = current.mixingFrom;
interrupt = false;
} else } else
disposeNext(current); disposeNext(current);
} }
var entry:TrackEntry = trackEntry(trackIndex, animation, loop, current); var entry:TrackEntry = trackEntry(trackIndex, animation, loop, current);
setCurrent(trackIndex, entry); setCurrent(trackIndex, entry, interrupt);
queue.drain(); queue.drain();
return entry; return entry;
} }
@ -417,7 +419,7 @@ public class AnimationState {
var entry:TrackEntry = trackEntry(trackIndex, animation, loop, last); var entry:TrackEntry = trackEntry(trackIndex, animation, loop, last);
if (last == null) { if (last == null) {
setCurrent(trackIndex, entry); setCurrent(trackIndex, entry, true);
queue.drain(); queue.drain();
} else { } else {
last.next = entry; last.next = entry;