13
我正在開發一個使用LibGDX的Android遊戲。菜單屏幕上有4個按鈕,但這些按鈕的ClickListener
不起作用。按鈕ClickListener不能在LibGDX遊戲中工作
// retrieve the custom skin for our 2D widgets
Skin skin = super.getSkin();
// create the table actor and add it to the stage
table = new Table(skin);
table.width = stage.width();
table.height = stage.height();
stage.addActor(table);
// retrieve the table's layout
TableLayout layout = table.getTableLayout();
// register the button "start game"
TextButton startGameButton = new TextButton("Start game", skin);
startGameButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
System.out.println("hiii");
Assets.load();
// game.getSoundManager().play(TyrianSound.CLICK);
game.setScreen(new GameScreen(game));
}
});
layout.register("startGameButton", startGameButton);
如何激活LibGDX中的按鈕ClickListener
?
它現在單擊作爲方法名稱,用小寫「c」開始。 – 2013-05-14 01:42:09
此外,現在它是'startGameButton.addListener' – 2014-10-29 19:02:59