我的Libgdx上的Table属性存在问题:
Table root = new Table();
root.setFillParent(true);
stage.addActor(root);
Table table = new Table(MyGdxGame.gameSkin);
table.setBackground(new NinePatchDrawable(getNinePatch(("background.jpg"))));
root.add(table).grow().pad(25.0f);
Label label = new Label("Marsel\nTale", MyGdxGame.gameSkin, "title");
label.setColor(Color.WHITE);
label.setScale(.9f,.9f);
table.add(label);
table.row();
TextButton playButton = new TextButton("Tournament",MyGdxGame.gameSkin);
playButton.addListener(new InputListener(){
@Override
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
game.setScreen(new ChampionScreen(game));
}
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
return true;
}
});
table.add(playButton);
TextButton optionsButton = new TextButton("Options",MyGdxGame.gameSkin);
optionsButton.addListener(new InputListener(){
@Override
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
game.setScreen(new OptionScreen(game));
}
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
return true;
}
});
table.add(optionsButton).padBottom(3.0f);
我无法修改表格的结构,我想将playButton和optionButton放在底部。
答案 0 :(得分:1)
应该有一个名为bottom()
的方法,您可以在按钮上使用,如:
table.add(playButton).bottom();
可以在这篇有用的文章中找到更多信息:https://github.com/libgdx/libgdx/wiki/Table