Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

Actions.fadeOut doesn't work when called on stage root

$
0
0

I’m trying to fade out my screen when a button is pressed, but the following code doesn’t work:

public void switchScreen(final Game game, final Screen newScreen){
        stage.getRoot().getColor().a = 1;
        SequenceAction sequenceAction = new SequenceAction();
        sequenceAction.addAction(Actions.fadeOut(3f));
        sequenceAction.addAction(Actions.run(new Runnable() {
            @Override
            public void run() {
                game.setScreen(newScreen);
            }
        }));
        stage.getRoot().addAction(sequenceAction);
    }

If I change the line sequenceAction.addAction(Actions.fadeOut(3f)); to sequenceAction.addAction(Actions.moveTo(200, 200, 3f)); then it works as expected, but for some reason fadeOut does nothing. All the application does is pause for 3 seconds, then immediately switch to the new screen.


Viewing all articles
Browse latest Browse all 434

Trending Articles