Fix going back on the Customize screen
This commit is contained in:
parent
07527966b6
commit
6a45790538
1 changed files with 14 additions and 4 deletions
|
@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue