简体   繁体   中英

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. I read somewhere that an InputProcessor can solve this issue. 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. 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. Then catch the input and don't let it add to the text field. Its a hack, but it might work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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