java - How to approach Inputprocessing -
i trying build options menu in libgdx using scene2d , im trying find way how approach user input.
i want implement going mainmenu when key on android pressed, not sure how it, since rest of input (pressing button ) handled stage.
if have idea on how approach issue , how handle user input correctly please respond. did not include code since more how approach it, instead of actual problem in code.
thanks, valentin
you need create inputprocessor , implement methods, there no way around because key separate stage. need have way access main menu object inputprocessor; assuming using game , screens, 1 way of doing it:
public class optionsscreen implements screen, inputprocessor { final mygame game; public optionsscreen(mygame game) { this.game = game; } ... @override public boolean keyup(int keycode) { if(keycode == keys.back) { game.setscreen(game.mainscreen); return true; } return false; } ... }
where game.mainscreen
screen of main menu. newly created instance. of course, have enable key before being able catch via gdx.input.setcatchbackkey(true);
.
i hope answers question.
Comments
Post a Comment