首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Libgdx表结构

Libgdx表结构
EN

Stack Overflow用户
提问于 2017-07-16 03:17:14
回答 1查看 53关注 0票数 0

我在Libgdx的代码中遇到了一个表格属性的问题:

代码语言:javascript
复制
 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放在底部。

EN

回答 1

Stack Overflow用户

发布于 2017-07-17 03:25:40

应该有一个名为bottom()的方法可以在按钮上使用,如下所示:

代码语言:javascript
复制
table.add(playButton).bottom();

更多信息可以在这篇有用的文章中找到:https://github.com/libgdx/libgdx/wiki/Table

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45121913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档