@Override public boolean keyDown(int keycode) { if (keycode == Keys.LEFT) controller.leftPressed(); if (keycode == Keys.RIGHT) controller.rightPressed(); if (keycode == Keys.Z) controller.jumpPressed(); if (keycode == Keys.X) controller.firePressed(); if (keycode == Keys.D) renderer.toggleDebug(); return true; }
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (!Gdx.app.getType().equals(ApplicationType.Android)) return false; if (screenX < width / 2 && screenY > height / 2) controller.leftPressed(); if (screenX > width / 2 && screenY > height / 2) controller.rightPressed(); if (screenX < width / 2 && screenY < height / 2) controller.jumpPressed(); // top left // if (screenX > width /2 && screenY < height /2) controller.firePressed(); // top right if (screenX > width / 2 && screenY < height / 2) controller.jumpPressed(); // top right return true; }
@Override public boolean touchDragged(int screenX, int screenY, int pointer) { if (!Gdx.app.getType().equals(ApplicationType.Android)) return false; // fix for dragging past the touch zones if (screenX < width / 2 && screenY < height / 2) controller.leftReleased(); if (screenX > width / 2 && screenY < height / 2) controller.rightReleased(); if (screenX > width / 2 && screenY > height / 2) { controller.leftReleased(); controller.rightPressed(); } if (screenX < width / 2 && screenY > height / 2) { controller.rightReleased(); controller.leftPressed(); } return true; }