我在Libgdx的代码中遇到了一个表格属性的问题:
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放在底部。
发布于 2017-07-17 03:25:40
应该有一个名为bottom()的方法可以在按钮上使用,如下所示:
table.add(playButton).bottom();更多信息可以在这篇有用的文章中找到:https://github.com/libgdx/libgdx/wiki/Table
https://stackoverflow.com/questions/45121913
复制相似问题