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

how to create a simple dialog pop up on back button press in libgdx game

$
0
0

Can anybody guide me how to create a simple dialog pop up on back button press in LIBGDX game.
I tried it by reading Dialog APi, but nothing happens becuase of my lack of knowledge. So kindly point out my mistake and let me know.

private Dialog di;

I know how to catch back button

in GameScreen Constructor I give

    di = new Dialog("Settings", skindialog);
    di.setSize(400, 500);
    di.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2); 
    Gdx.input.setCatchBackKey(true);

In renderer method I give
di.button(button);
di.getButtonTable().row();
di.button(go);
di.getButtonTable().add(button).pad(20);
di.getButtonTable().add(go).pad(20);

if (Gdx.input.isKeyPressed(Keys.BACK)) {

// I dont know how to start the dialog here
}

I tried this as well
@Override
public void show() {
Gdx.app.log(“GameScreen”, “show called”);

        di.show(stage);
}

Kindly Let me know. I just want 3 buttons on this dialog and it appears on game screen if user press back. Three buttons should be MainMenu, ResumeGame and Quit.
But at First I dont know how to create dialog plus what type of buttos I should attach here Plus if It want a stage to be drawn onto.


Viewing all articles
Browse latest Browse all 434

Trending Articles