Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libgdx animation callback?

How do I check if current animation is completed so that I can follow up with another set of animation? For example, I am playing player hurt animation and I want to play some bloods splashing animation (different spritesheet) once the player hurt animation is finished.

like image 334
Iain H. Avatar asked Sep 10 '26 05:09

Iain H.


1 Answers

You can set OnActionCompleted listener to your Action with Action's method:

 /** 
  * Sets the listener to be invoked when the action is finished.
  * @param listener
  * @return this 
  */
 public Action setCompletionListener (final OnActionCompleted listener)

Eventually you can use:

public boolean isDone()

to check if Action execution has finished.

like image 166
Ludevik Avatar answered Sep 12 '26 19:09

Ludevik