Fixed AnimationState bug.

This commit is contained in:
NathanSweet 2013-04-02 18:45:25 +02:00
parent 0c1c0a3dc6
commit 7d7e56bb24
2 changed files with 8 additions and 9 deletions

View File

@ -78,13 +78,15 @@ void AnimationState_setAnimation (AnimationState* self, Animation* newAnimation,
if (internal->mixDuration > 0) { if (internal->mixDuration > 0) {
internal->mixTime = 0; internal->mixTime = 0;
internal->previous = self->animation; internal->previous = self->animation;
internal->previousTime = self->time;
internal->previousLoop = self->loop;
} }
} }
CONST_CAST(Animation*, self->animation) = newAnimation; CONST_CAST(Animation*, self->animation) = newAnimation;
self->loop = loop; self->loop = loop;
self->time = 0; self->time = 0;
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -60,25 +60,22 @@ public class AnimationState {
current.apply(skeleton, currentTime, currentLoop); current.apply(skeleton, currentTime, currentLoop);
} }
/** Set the current animation. */ /** Set the current animation. The current animation time is set to 0.
* @param animation May be null. */
public void setAnimation (Animation animation, boolean loop) { public void setAnimation (Animation animation, boolean loop) {
setAnimation(animation, loop, 0);
}
/** Set the current animation.
* @param time The time within the animation to start. */
public void setAnimation (Animation animation, boolean loop, float time) {
previous = null; previous = null;
if (animation != null && current != null) { if (animation != null && current != null) {
mixDuration = data.getMix(current, animation); mixDuration = data.getMix(current, animation);
if (mixDuration > 0) { if (mixDuration > 0) {
mixTime = 0; mixTime = 0;
previous = current; previous = current;
previousTime = currentTime;
previousLoop = currentLoop;
} }
} }
current = animation; current = animation;
currentLoop = loop; currentLoop = loop;
currentTime = time; currentTime = 0;
} }
/** @return May be null. */ /** @return May be null. */