简体   繁体   English

LibGDX InputProcessor在Android上不起作用

[英]LibGDX InputProcessor doesn't work on android

Im making a text based game so of course, input is vital. 我在制作基于文本的游戏,因此输入当然至关重要。 On desktop i can simply poll key press events and this works fine. 在桌面上,我可以简单地轮询按键事件,并且效果很好。 However it doesnt work with androids sot keyboard. 但是,它不适用于android sot键盘。 I read somewhere that an InputProcessor can solve this issue. 我在某处读到InputProcessor可以解决此问题。 However, i have tried this and doesnt seem to work, heres my code: 但是,我已经尝试过了,似乎没有用,这是我的代码:

 //in method called on Screen load
 Gdx.input.setInputProcessor(this);

//same class, later on
public boolean keyDown(int keycode) {
 //do stuff
 }

"stuff" happens on desktop but not on Android. “内容”发生在台式机上,而不发生在Android上。 However, i have noticed it works with some keyboard in the market and not others. 但是,我注意到它可以与市场上的某些键盘一起使用,而不适用于其他键盘。 Why is this? 为什么是这样? What can i do, any alternatives? 我该怎么办,还有其他选择吗?

Try making a textField and giving it focus. 尝试制作一个textField并使其聚焦。 Then catch the input and don't let it add to the text field. 然后捕获输入,不要将其添加到文本字段中。 Its a hack, but it might work 这是一个hack,但它可能会起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM