Registering a listener doesn't affect playback behavior. You'd need to set the trackEnd
time if you want the track cleared. That could be useful eg when an animation changes something and it stays that way, like a door opening.
The end
event occurs "when this entry will never be applied again". If you don't want to set trackEnd
to clear the track, then it's not the right event for your use case. If you want to do something when the trackTime
reaches the animation duration, then you can use the complete
event. For a non-looping animation it will only happen once. For looping if you only care about eg the first complete
event, you can ignore it if entry.trackTime >= entry.animation.duration * 2
.
Depending on your needs, another way to do it could be to queue the next animation. Eg, if you set an attack
animation, also add an idle
animation after it (or whatever you need, maybe an empty animation to go back to the setup pose). If something else happens, you'd set a new animation and add idle
after it. This way you don't need to listen for complete
, but means you probably want to set a new animation, not add it to the existing queue (which would go after idle
). There is a way to clear an entry from the queue, using AnimationState clearNext
, so that could be used to remove idle
, then add something else.
I agree, the image shows the behavior as if trackEnd
is set, but the code shown doesn't set it. We'll see about improving it.