• Runtimes
  • AnimationState problems after update

Hi!

I've updated the spine libgdx runtime, and my "old" AnimationState code doesn't work now.

I changed this:

[b]setAnimation(animation,loop);[/b]

By this:

[b]trackEntryVariable = setAnimation(0,animation,loop);[/b]

and to check if animation is completed:

[b]trackEntryVariable.isComplete();[/b]

In my update method:

[b]mState.update(time);
mState.apply(mSkeleton);[/b]

And now, nothing is moving :S. I'm not using addAnimation methods, just setAnimation, without mixes.

Any tips? Maybe missunderstood trackIndex or something?

Thanks in advance.

Related Discussions
...
  • Изменено

Track index should be zero if you don't apply multiple animations at the same time. The code you described looks correct. The examples work so it should work for you. What runtime? Can you debug it further? Verify the time you pass to update is correct (which should be the time since the last call to update), step into update() and see if there is a track entry, etc.

Hi! Thank you for your quick response 🙂

As I said, I'm using LibGDX runtime.

I debbugged this, and I've found this:

  • I always pass the delta time to the update method (not accumulative time).
  • This condition (inside AnimationState.update()):

if (!current.loop && current.lastTime >= current.endTime) {
clearTrack(i);
}

It's true inmediatly, the track is cleared, and the animation isn't showed.

  • This condition (inside TrackEntry)

public boolean isComplete () {
return time >= endTime;
}

Is false always, because time isn't update again.

What is the value of current.lastTime and current.endTime just before clearTrack is called? endTime should be the animation's duration.

current.lastTime: 1.0319542 - current.endTime: 0.8666

I get this adding a System.out.println inside this conditional statement:

if (!current.loop && current.lastTime >= current.endTime) {
clearTrack(i);
}

I'm doing things like in this testcase
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java

It's like lastTime is increasing when the animation isn't set yet. When the animation is set, the time is greater than endTime and nothing happens.

Is there any difference in JSON file? Do I need to re-export it? I'm using an old JSON.

I'm going to test over your testcase, this is really weird :nerd:

I think there was a problem with lastTime not getting set to zero for a new TrackEntry. They are pooled, so if reused the first frame of a new animation could be the lastTime from a previous animation


not good! Fixed in git.

Thank you Nate! Everything works perfect now 🙂