Libgdx - Making a drop-down menu/settings screen

2019-07-31 16:15发布

问题:

I'm looking to make a drop-down menu and drop-down settings screen but I couldn't find any resources for making these in Libgdx. Would like some pointers to good resources for this specific type of interface or a quick example.

Thanks!

回答1:

SelectBox is in LibGDX can be used for drop-down list, it allows one of a number of values to be chosen from a list. And for pop-up window you can use Dialog.

stage=new Stage();

Skin skin=new Skin(Gdx.files.internal("skin/glassy-ui.json"));

dialog=new Dialog("Setting",skin);
dialog.setSize(200,200);
dialog.setPosition(Gdx.graphics.getWidth()/2-100,Gdx.graphics.getHeight()/2-100);

final SelectBox<String> selectBox=new SelectBox<String>(skin);
selectBox.setItems("XYZ","ABC","PQR","LMN");

dialog.getContentTable().defaults().pad(10);
dialog.getContentTable().add(selectBox);

stage.addActor(dialog);
Gdx.input.setInputProcessor(stage);

Output