Fix going back on the Customize screen

This commit is contained in:
Lonami Exo 2017-02-01 10:49:39 +01:00
parent 07527966b6
commit 6a45790538

View file

@ -30,6 +30,8 @@ class CustomizeScreen implements Screen {
private Klooni game; private Klooni game;
private Stage stage; private Stage stage;
private final Screen lastScreen;
//endregion //endregion
//region Static members //region Static members
@ -45,6 +47,7 @@ class CustomizeScreen implements Screen {
final GameLayout layout = new GameLayout(); final GameLayout layout = new GameLayout();
this.game = game; this.game = game;
this.lastScreen = lastScreen;
stage = new Stage(); stage = new Stage();
Table table = new Table(); Table table = new Table();
@ -59,8 +62,7 @@ class CustomizeScreen implements Screen {
backButton.addListener(new ChangeListener() { backButton.addListener(new ChangeListener() {
@Override @Override
public void changed(ChangeEvent event, Actor actor) { public void changed(ChangeEvent event, Actor actor) {
CustomizeScreen.this.game.setScreen(lastScreen); goBack();
dispose();
} }
}); });
optionsGroup.addActor(backButton); optionsGroup.addActor(backButton);
@ -127,6 +129,15 @@ class CustomizeScreen implements Screen {
//endregion //endregion
//region Private methods
private void goBack() {
CustomizeScreen.this.game.setScreen(lastScreen);
dispose();
}
//endregion
//region Public methods //region Public methods
@Override @Override
@ -142,8 +153,7 @@ class CustomizeScreen implements Screen {
stage.draw(); stage.draw();
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) { if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) {
game.setScreen(new MainMenuScreen(game)); goBack();
dispose();
} }
} }