Better delay adjustment.

This commit is contained in:
NathanSweet 2013-10-17 01:13:11 +02:00
parent c25809fa4f
commit 3a1aac897c
6 changed files with 20 additions and 19 deletions

View File

@ -201,9 +201,10 @@ public class AnimationState {
_tracks[trackIndex] = entry; _tracks[trackIndex] = entry;
if (delay <= 0) { if (delay <= 0) {
if (last) if (last) {
delay += Math.max(0, last.endTime - last.time) - _data.getMix(last.animation, animation); if (last.time < last.endTime) delay += last.endTime - last.time;
else delay -= _data.getMix(last.animation, animation);
} else
delay = 0; delay = 0;
} }
entry.delay = delay; entry.delay = delay;

View File

@ -266,10 +266,8 @@ spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIn
if (delay <= 0) { if (delay <= 0) {
if (last) { if (last) {
float remaining = last->endTime - last->time; if (last->time < last->endTime) delay += last->endTime - last->time;
if (remaining < 0) remaining = 0; delay -= spAnimationStateData_getMix(self->data, last->animation, animation);
delay += remaining;
if (animation) delay -= spAnimationStateData_getMix(self->data, last->animation, animation);
} else } else
delay = 0; delay = 0;
} }

View File

@ -213,9 +213,10 @@ namespace Spine {
tracks[trackIndex] = entry; tracks[trackIndex] = entry;
if (delay <= 0) { if (delay <= 0) {
if (last != null) if (last != null) {
delay += Math.Max(0, last.endTime - last.time) - data.GetMix(last.animation, animation); if (last.time < last.endTime) delay += last.endTime - last.time;
else delay -= data.GetMix(last.animation, animation);
} else
delay = 0; delay = 0;
} }
entry.delay = delay; entry.delay = delay;

View File

@ -1109,9 +1109,10 @@ spine.AnimationState.prototype = {
this.tracks[trackIndex] = entry; this.tracks[trackIndex] = entry;
if (delay <= 0) { if (delay <= 0) {
if (last) if (last) {
delay += last.endTime - this.data.getMix(last.animation, animation); if (last.time < last.endTime) delay += last.endTime - last.time;
else delay -= this.data.getMix(last.animation, animation);
} else
delay = 0; delay = 0;
} }
entry.delay = delay; entry.delay = delay;

View File

@ -232,9 +232,10 @@ public class AnimationState {
tracks.set(trackIndex, entry); tracks.set(trackIndex, entry);
if (delay <= 0) { if (delay <= 0) {
if (last != null) if (last != null) {
delay += Math.max(0, last.endTime - last.time) - data.getMix(last.animation, animation); if (last.time < last.endTime) delay += last.endTime - last.time;
else delay -= data.getMix(last.animation, animation);
} else
delay = 0; delay = 0;
} }
entry.delay = delay; entry.delay = delay;

View File

@ -201,9 +201,8 @@ function AnimationState.new (data)
delay = delay or 0 delay = delay or 0
if delay <= 0 then if delay <= 0 then
if last then if last then
local remaining = last.endTime - last.time if last.time < last.endTime then delay = delay + last.endTime - last.time end
if remaining < 0 then remaining = 0 end delay = delay - self.data:getMix(last.animation.name, animation.name)
delay = delay + remaining - self.data:getMix(last.animation.name, animation.name)
else else
delay = 0 delay = 0
end end