Better lastTime calculation.

This commit is contained in:
NathanSweet 2013-08-15 12:03:02 +02:00
parent 35ec341907
commit acf515cbb6

View File

@ -46,7 +46,6 @@ public class AnimationState {
} }
public void update (float delta) { public void update (float delta) {
currentLastTime = currentTime;
currentTime += delta; currentTime += delta;
previousTime += delta; previousTime += delta;
mixTime += delta; mixTime += delta;
@ -96,6 +95,8 @@ public class AnimationState {
for (int ii = 0; ii < listenerCount; ii++) for (int ii = 0; ii < listenerCount; ii++)
listeners.get(ii).event(event); listeners.get(ii).event(event);
} }
currentLastTime = currentTime;
} }
public void clearAnimation () { public void clearAnimation () {
@ -129,6 +130,7 @@ public class AnimationState {
current = animation; current = animation;
currentLoop = loop; currentLoop = loop;
currentTime = 0; currentTime = 0;
currentLastTime = 0;
currentListener = listener; currentListener = listener;
if (currentListener != null) currentListener.start(); if (currentListener != null) currentListener.start();
@ -213,6 +215,7 @@ public class AnimationState {
public void setTime (float time) { public void setTime (float time) {
currentTime = time; currentTime = time;
currentLastTime = time;
} }
/** Returns true if no animation is set or if the current time is greater than the animation duration, regardless of looping. */ /** Returns true if no animation is set or if the current time is greater than the animation duration, regardless of looping. */