I've been having trouble with getting scene2d to erase my old texture when I switch screens, and also when I change my label the old label string is still drawn underneath.
public StartScreen(MainGame game){
this.mainGame = game;
viewport = new FitViewport(640, 360, new OrthographicCamera());
stage = new Stage(viewport, game.batch);
Texture button = new Texture("playButton.png");
Button.ButtonStyle bs = new Button.ButtonStyle();
bs.up = new TextureRegionDrawable(new TextureRegion(button));
startGameButton = new Button(bs);
Table table = new Table();
table.top();
table.setFillParent(true);
table.add(startGameButton).expandX().padTop(10);
stage.addActor(table);
startGameButton.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
mainGame.SetClassScreen();
}
});
Gdx.input.setInputProcessor(stage);
}
public void render(float delta) {
mainGame.batch.setProjectionMatrix(stage.getCamera().combined);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
In the constructor I have tried using Dispose() when changing the screen and it doesn't work.
When the screens are changed, The playButton still shows in the next screen. I also have a Label which displays text depending on a button pressed, but when it's pressed it writes the string over the old string to look like a jumbled mess.
I have a feeling I'm not updating something to be redrawn somewhere but I can't find it.
public PickClassScreen(MainGame game){
this.mainGame = game;
viewport = new FitViewport(640, 360, new OrthographicCamera());
stage = new Stage(viewport, game.batch);
//All initialization of Scene2d stuff.
stage.addActor(table);
Gdx.input.setInputProcessor(stage);
}
@Override
public void show() {
}
@Override
public void render(float delta) {
mainGame.batch.setProjectionMatrix(stage.getCamera().combined);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
The screen that I am switching to. ^
SetClassScreen
method do? \$\endgroup\$PlayScreen
look like? Are you setting up aStage
in that as well? \$\endgroup\$