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:

  1. make screens implement inputprocessor.
  2. set gdx.input.setinputprocessor() screen (in show() create() or name of method called when screen set)
  3. override touchup()
  4. 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

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -