Esempio n. 1
0
  public void resize(int width, int height) {
    renderer.setSize(width, height);
    this.width = width;
    this.height = height;
    buttonSize = height / 6F;

    left.set(buttonSize / 2F, buttonSize / 2F, buttonSize, buttonSize);
    right.set(buttonSize * 2, buttonSize / 2F, buttonSize, buttonSize);

    jump.set(width - (buttonSize * 3 / 2), buttonSize / 2F, buttonSize, buttonSize);
  }
Esempio n. 2
0
  public boolean touchUp(int x, int y, int pointer, int button) {
    if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
      if (left.contains(x, (y - height) * -1)) {
        controller.leftReleased();
      }

      if (right.contains(x, (y - height) * -1)) {
        controller.rightReleased();
      }

      if (jump.contains(x, (y - height) * -1)) {
        controller.jumpReleased();
      }
      return true;
    }
    return false;
  }
Esempio n. 3
0
  public boolean touchDragged(int x, int y, int pointer) {
    if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
      if (controller.isLeftDown()
          && !left.contains(x, (y - height) * -1)
          && controller.leftPointer == pointer) {
        controller.leftReleased();
      }
      if (controller.isRightDown()
          && !right.contains(x, (y - height) * -1)
          && controller.rightPointer == pointer) {
        controller.rightReleased();
      }
      if (controller.isJumpDown()
          && !jump.contains(x, (y - height) * -1)
          && controller.jumpPointer == pointer) {
        controller.jumpReleased();
      }

      if (!controller.isLeftDown()
          && left.contains(x, (y - height) * -1)
          && controller.leftPointer == -1) {
        controller.leftPressed(pointer);
      }

      if (!controller.isRightDown()
          && right.contains(x, (y - height) * -1)
          && controller.rightPointer == -1) {
        controller.rightPressed(pointer);
      }

      if (!controller.isJumpDown()
          && jump.contains(x, (y - height) * -1)
          && controller.jumpPointer == -1) {
        controller.jumpPressed(pointer);
      }
      return true;
    }
    return false;
  }