android - [LibGDX]Delay between button presses -
im making simple game , have started making each menu. there 3 menus in row - main menu - playher select menu - gamemode menu problem facing atm adding delay between touches. code have uses sprites buttons , detects whether touch point within bounding rectangle.
like so: if(gdx.input.istouched()){
cam.unproject(playermenutp.set(gdx.input.getx(), gdx.input.gety(), 0)); if(sprites[1].getboundingrectangle().contains(playermenutp.x, playermenutp.y)){ game.changescreen(2); }}
this works first menu since buttons in exact same position on each menu if hold finger on screen skips through menus.
i don't know how modify wait until previous touch no longer occurring continue scan one.
any appreciated.
thanks
i suggest use scene2d ui related stuff, it's not hard implement or learn, , easy mantain.
anyway if want keep going in way, can this:
- make screens implement inputprocessor.
- set gdx.input.setinputprocessor() screen (in show() create() or name of method called when screen set)
- override touchup()
replace code with
@override public boolean touchup (int screenx, int screeny, int pointer, int button) { cam.unproject(playermenutp.set(screenx, screeny, 0)); if (sprites[1].getboundingrectangle().contains(playermenutp.x, playermenutp.y)){ game.changescreen(2); } return true;
}
Comments
Post a Comment