Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void handleInput() {
- float x0 = (Gdx.input.getX(0) / (float)Gdx.graphics.getWidth()) * 960;
- float x1 = (Gdx.input.getX(1) / (float)Gdx.graphics.getWidth()) * 960;
- float y0 = (Gdx.input.getY(0) / (float)Gdx.graphics.getHeight()) * 640;
- float y1 = (Gdx.input.getY(1) / (float)Gdx.graphics.getHeight()) * 640;
- boolean jumpButton = (Gdx.input.isTouched(0) && x0 > 850 && x0 < 850+80 && y0 > 640-80);
- 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)));
- 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)));
- if (jumpButton) {
- // player jumps
- }
- if (leftButton) {
- // player walks to the left
- } else if (rightButton) {
- // player walks to the right
- } else {
- // player stops walking
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement