Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libgdx how execute code after an action?

Tags:

java

libgdx

How is possible to execute Java code after actor's action?

It's very important for me to execute this Java code once.

like image 893
forsaken122 Avatar asked Mar 12 '26 01:03

forsaken122


1 Answers

Yes, there is RunnableAction for that, to which you supply a Runnable. You can queue it via a SequenceAction.

import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;

Actor actor = new Image();
actor.addAction(moveTo(10, 20, 0.5f));
RunnableAction run = new RunnableAction();
run.setRunnable(new Runnable() {
    @Override
    public void run() {
        System.out.println("LEEEROOOOOY JEEEEEEENKINS");
    }
});
actor.addAction(sequence(moveTo(200, 100, 2), run));
like image 128
noone Avatar answered Mar 13 '26 15:03

noone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!