禁用TextButton

时间:2014-05-18 21:03:33

标签: libgdx

我正在尝试禁用我编码的TextButton,如下所示:

    // Setup new game button
    final TextButton newGameButton = new TextButton("New Game", style);
    newGameButton.addListener(new InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y,
                int pointer, int button) {
            Tyr.getInstance().setScreen(new GameScreen());
            AudioHelper.stopMusic();
            return true;
        }
    });
    table.add(newGameButton).spaceBottom(BUTTON_SPACE);
    table.row();

然而," setDisabled(true)"功能似乎不起作用。还有其他方法可以完成这项任务吗?

1 个答案:

答案 0 :(得分:20)

找到解决方案:“newGameButton.setTouchable(Touchable.disabled);”