gpt4 book ai didi

java - Inputlistener 不处理 actor 的输入

转载 作者:行者123 更新时间:2023-11-29 21:38:13 25 4
gpt4 key购买 nike

我将下表按钮放入 MenuScreen.java 文件中以制作“开始游戏”按钮:

// register the button "start game"
TextButton startGameButton = new TextButton( "Start game", getSkin() );
startGameButton.setTouchable(Touchable.enabled);
startGameButton.addListener( new InputListener() {

public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
System.out.println("down");
Gdx.app.log( HowDrunkAreYou.LOG, "touch d" );
return true;
}

public void touchUp(
InputEvent event,
float x,
float y,
int pointer,
int button )
{
Gdx.app.log( HowDrunkAreYou.LOG, "touch d" );
super.touchUp( event, x, y, pointer, button );
game.getSoundManager().play( HowDrunkAreYouSound.CLICK );
//game.setScreen( new StartGameScreen( game ) );
}
} );
table.add( startGameButton ).size( 300, 60 ).uniform().spaceBottom( 10 );

由于某种原因,输入处理程序永远不会触发,Java 调试器永远不会进入该方法。我错过了什么?我已经在桌面和安卓上测试过,结果相同。

logcat 或控制台都没有给我任何关于可能是什么错误的信息。

谢谢!

最佳答案

您需要在代码中使用 Gdx.input.setInputProcessor(stage)。此链接将为您提供帮助。 steigert blogspot

现在我只能告诉你的是,你需要制作一个舞台,向其添加表格,并将舞台传递给 setinputprocessor() 。有关更多详细信息,请参阅此链接,您将了解有关舞台和使用表格的更多信息

关于java - Inputlistener 不处理 actor 的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17808143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com