potato
potato

Reputation: 4589

completion handler for scene2d actions

Is there a completion handler for scene2d actions we can use? I would like to trigger additional code when action ends. I found this function, but there is probably a more robust way of getting notified when action ends.

float delay = 1; // seconds

Timer.schedule(new Task(){
    @Override
    public void run() {
        // Do your work
    }
}, delay);

Upvotes: 0

Views: 122

Answers (1)

asherbret
asherbret

Reputation: 6018

Use the SequenceAction:

The following example creates an Action that move an Actor to (5, 5) and then runs whatever is in the Runnable:

SequenceAction sequenceAction = Actions.sequence(Actions.moveTo(5, 5), Actions.run(new Runnable() {
    @Override
    public void run() {
        // When this runs, that means the previous Action is complete. 
    }
}));

Upvotes: 2

Related Questions