Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public void handleInput() {
  2. float x0 = (Gdx.input.getX(0) / (float)Gdx.graphics.getWidth()) * 960;
  3. float x1 = (Gdx.input.getX(1) / (float)Gdx.graphics.getWidth()) * 960;
  4. float y0 = (Gdx.input.getY(0) / (float)Gdx.graphics.getHeight()) * 640;
  5. float y1 = (Gdx.input.getY(1) / (float)Gdx.graphics.getHeight()) * 640;
  6.  
  7. boolean jumpButton = (Gdx.input.isTouched(0) && x0 > 850 && x0 < 850+80 && y0 > 640-80);
  8. boolean leftButton = ( ((Gdx.input.isTouched(0) && x0 < 25+80) || (Gdx.input.isTouched(1) && x1 < 25+80)) && ((Gdx.input.isTouched(0) && x0 > 25) || (Gdx.input.isTouched(1) && x1 > 25)) && ((Gdx.input.isTouched(0) && y0 > 640-80) || (Gdx.input.isTouched(1) && y1 > 640-80)));
  9. boolean rightButton = ( ((Gdx.input.isTouched(0) && x0 < 125+80) || (Gdx.input.isTouched(1) && x1 < 125+80)) && ((Gdx.input.isTouched(0) && x0 > 125) || (Gdx.input.isTouched(1) && x1 > 125)) && ((Gdx.input.isTouched(0) && y0 > 640-80) || (Gdx.input.isTouched(1) && y1 > 640-80)));
  10.  
  11. if (jumpButton) {
  12. // player jumps
  13. }
  14. if (leftButton) {
  15. // player walks to the left
  16. } else if (rightButton) {
  17. // player walks to the right
  18. } else {
  19. // player stops walking
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement