mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[as3] Ported Animation State changes, see #908
This commit is contained in:
parent
7593da8cb8
commit
679a1997c0
Binary file not shown.
@ -39,6 +39,7 @@ package spine.animation {
|
||||
public static var SUBSEQUENT : int = 0;
|
||||
public static var FIRST : int = 1;
|
||||
public static var DIP : int = 2;
|
||||
public static var DIP_MIX : int = 3;
|
||||
internal static var emptyAnimation : Animation = new Animation("<empty>", new Vector.<Timeline>(), 0);
|
||||
public var data : AnimationStateData;
|
||||
public var tracks : Vector.<TrackEntry> = new Vector.<TrackEntry>();
|
||||
@ -107,7 +108,7 @@ package spine.animation {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (current.mixingFrom != null && updateMixingFrom(current, delta, 2)) {
|
||||
if (current.mixingFrom != null && updateMixingFrom(current, delta)) {
|
||||
// End mixing from entries once all have completed.
|
||||
var from : TrackEntry = current.mixingFrom;
|
||||
current.mixingFrom = null;
|
||||
@ -123,21 +124,18 @@ package spine.animation {
|
||||
queue.drain();
|
||||
}
|
||||
|
||||
private function updateMixingFrom(entry : TrackEntry, delta : Number, animationCount : int) : Boolean {
|
||||
var from : TrackEntry = entry.mixingFrom;
|
||||
private function updateMixingFrom(to : TrackEntry, delta : Number) : Boolean {
|
||||
var from : TrackEntry = to.mixingFrom;
|
||||
if (from == null) return true;
|
||||
|
||||
var finished : Boolean = updateMixingFrom(from, delta, animationCount + 1);
|
||||
var finished : Boolean = updateMixingFrom(from, delta);
|
||||
|
||||
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
|
||||
if (entry.mixTime > 0 && (entry.mixTime >= entry.mixDuration || entry.timeScale == 0)) {
|
||||
if (animationCount > 5 && from.mixingFrom == null) {
|
||||
// Limit linked list by speeding up and removing old entries.
|
||||
entry.interruptAlpha = Math.max(0, entry.interruptAlpha - delta * 0.66);
|
||||
if (entry.interruptAlpha <= 0) {
|
||||
entry.mixingFrom = null;
|
||||
queue.end(from);
|
||||
}
|
||||
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
|
||||
if (from.totalAlpha == 0) {
|
||||
to.mixingFrom = from.mixingFrom;
|
||||
to.interruptAlpha = from.interruptAlpha;
|
||||
queue.end(from);
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
@ -145,7 +143,7 @@ package spine.animation {
|
||||
from.animationLast = from.nextAnimationLast;
|
||||
from.trackLast = from.nextTrackLast;
|
||||
from.trackTime += delta * from.timeScale;
|
||||
entry.mixTime += delta * entry.timeScale;
|
||||
to.mixTime += delta * to.timeScale;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -184,9 +182,9 @@ package spine.animation {
|
||||
for (ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline : Timeline = timelines[ii];
|
||||
if (timeline is RotateTimeline) {
|
||||
applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] > 0, timelinesRotation, ii << 1, firstFrame);
|
||||
applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
} else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] > 0, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= FIRST, false);
|
||||
}
|
||||
}
|
||||
queueEvents(current, animationTime);
|
||||
@ -226,6 +224,7 @@ package spine.animation {
|
||||
var alphaDip : Number = from.alpha * to.interruptAlpha;
|
||||
var alphaMix : Number = alphaDip * (1 - mix);
|
||||
var alpha : Number = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i : int = 0; i < timelineCount; i++) {
|
||||
var timeline : Timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
@ -237,13 +236,18 @@ package spine.animation {
|
||||
first = true;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case DIP:
|
||||
first = true;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
alpha = alphaDip;
|
||||
var dipMix : TrackEntry = timelineDipMix[i];
|
||||
if (dipMix != null) alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
break;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline is RotateTimeline)
|
||||
applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
|
||||
@ -46,7 +46,7 @@ package spine.animation {
|
||||
public var eventThreshold : Number, attachmentThreshold : Number, drawOrderThreshold : Number;
|
||||
public var animationStart : Number, animationEnd : Number, animationLast : Number, nextAnimationLast : Number;
|
||||
public var delay : Number, trackTime : Number, trackLast : Number, nextTrackLast : Number, trackEnd : Number, timeScale : Number;
|
||||
public var alpha : Number, mixTime : Number, mixDuration : Number, interruptAlpha : Number;
|
||||
public var alpha : Number, mixTime : Number, mixDuration : Number, interruptAlpha : Number, totalAlpha : Number;
|
||||
public var timelineData : Vector.<int> = new Vector.<int>();
|
||||
public var timelineDipMix : Vector.<TrackEntry> = new Vector.<TrackEntry>();
|
||||
public var timelinesRotation : Vector.<Number> = new Vector.<Number>();
|
||||
@ -89,6 +89,7 @@ package spine.animation {
|
||||
var timelinesCount : int = animation.timelines.length;
|
||||
var timelineData : Vector.<int> = this.timelineData;
|
||||
timelineData.length = timelinesCount;
|
||||
this.timelineDipMix.length = 0;
|
||||
var timelineDipMix : Vector.<TrackEntry> = this.timelineDipMix;
|
||||
timelineDipMix.length = timelinesCount;
|
||||
|
||||
@ -101,16 +102,19 @@ package spine.animation {
|
||||
timelineData[i] = AnimationState.SUBSEQUENT;
|
||||
} else if (to == null || !to.hasTimeline(intId))
|
||||
timelineData[i] = AnimationState.FIRST;
|
||||
else {
|
||||
timelineData[i] = AnimationState.DIP;
|
||||
else {
|
||||
for (var ii : int = mixingToLast; ii >= 0; ii--) {
|
||||
var entry : TrackEntry = mixingTo[ii];
|
||||
if (!entry.hasTimeline(intId)) {
|
||||
if (entry.mixDuration > 0) timelineDipMix[i] = entry;
|
||||
continue outer;
|
||||
}
|
||||
if (entry.mixDuration > 0) {
|
||||
timelineData[i] = AnimationState.DIP_MIX;
|
||||
timelineDipMix[i] = entry;
|
||||
continue outer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
timelineDipMix[i] = null;
|
||||
timelineData[i] = AnimationState.DIP;
|
||||
}
|
||||
}
|
||||
return lastEntry;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user