karlozalb

Hi!

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

I changed this:

setAnimation(animation,loop);

By this:

trackEntryVariable = setAnimation(0,animation,loop);

and to check if animation is completed:

trackEntryVariable.isComplete();

In my update method:

mState.update(time);
mState.apply(mSkeleton);


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.
karlozalb
  • Mesajlar: 24

Nate

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.
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12213

karlozalb

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.
karlozalb
  • Mesajlar: 24

Nate

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

Nate
  • Mesajlar: 12213

karlozalb

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:
karlozalb
  • Mesajlar: 24

Nate

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.
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12213

karlozalb

Thank you Nate! Everything works perfect now :)
karlozalb
  • Mesajlar: 24


Dön Runtimes