When I show a Dialog with
someDialog.show(someStage);
The dialog show with default FadeIn action. And the stage fade in too. So it make my background fade along with the stage.
How can I prevent this to happen?
Edit: Here my example code:
In Screen show method:
Texture bg = new Texture(Gdx.files.internal(src));
stage = new Stage(game.getViewport(), batch);
stage.addActor(someDialog) //just normal dialog
render code:
@Override
public void render(float delta) {
super.render(delta);
getBatch().begin();
getBatch().draw(backgroundTexture, 0, 0, width, height);
getBatch().end();
getStage().act(delta);
getStage().draw();
time += delta;
}
I show the dialog when some event trigger:
dialog.show(getStage());
I have tried to put null as second parameter to the show method
dialog.show(getStage(), null);
and make both stage and dialog not fade in but a want to keep the effect for only dialog or at least not the background.
Stage doesn't clean up the SpriteBatch's color when it's done, so when the loop comes back around, the last-used color is still applied to the sprite batch. In your case, the last used color happens to be the dialog's color.
To fix this, add getBatch().setColor(Color.WHITE);
before your getBatch().draw(backgroundTexture, 0, 0, width, height);
line.
And I don't think your whole stage is fading. Right now, your background texture has nothing to do with the stage, except that they're both sharing use of the SpriteBatch.