Java Inputlistener不';不能在actor上处理输入
我将下表按钮放入MenuScreen.java文件中,以创建“开始游戏”按钮: 由于某些原因,输入处理程序从未启动,java调试器从未进入该方法。我错过了什么?我已经在桌面和安卓系统上测试过了,结果是一样的 logcat和console都没有向我提供有关可能出现的错误的任何信息Java Inputlistener不';不能在actor上处理输入,java,android,libgdx,scene,Java,Android,Libgdx,Scene,我将下表按钮放入MenuScreen.java文件中,以创建“开始游戏”按钮: 由于某些原因,输入处理程序从未启动,java调试器从未进入该方法。我错过了什么?我已经在桌面和安卓系统上测试过了,结果是一样的 logcat和console都没有向我提供有关可能出现的错误的任何信息 谢谢大家! 您需要在代码中使用Gdx.input.setInputProcessor(stage)。此链接将帮助您 现在我能告诉你们的是,你们需要制作一个stage,向其中添加表,然后将stage传递给setinputp
谢谢大家! 您需要在代码中使用Gdx.input.setInputProcessor(stage)。此链接将帮助您
现在我能告诉你们的是,你们需要制作一个stage,向其中添加表,然后将stage传递给setinputprocessor()。有关更多详细信息,请参阅此链接,您将了解有关stage和using tables的更多信息r u using stage??是的,那么你是否在代码中加入Gdx.input.setInputProcessor(stage)?我不这么认为。事实上我对这个很陌生。确切的舞台是什么?应该在哪里?我没有使用gdx.input.setinputprocessor。此链接将帮助您。现在我能告诉你们的是,你们需要制作一个stage,向其中添加表,然后将stage传递给setinputprocessor()。有关更多详细信息,请参阅此链接,您将了解有关stage和使用Tables的更多信息。谢谢,我阅读了教程,现在解决了它。我必须在我的abstractscreen文件中放入一个setInputProcessor命令。请作为答案提交,以便我可以接受。干杯
// 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 );