Exemple #1
0
  public boolean keyDown(int keycode) {
    if (keycode == Keys.LEFT) controller.leftPressed(-1);

    if (keycode == Keys.RIGHT) controller.rightPressed(-1);

    if (keycode == Keys.Z) controller.jumpPressed(-1);

    if (keycode == Keys.X) controller.firePressed(-1);

    if ((keycode == Keys.BACK) || (keycode == Keys.ESCAPE)) {
      finishLevel(ExitBlock.EXIT_NOCLEAR);
    }

    return true;
  }
Exemple #2
0
  public boolean touchDown(int x, int y, int pointer, int button) {
    if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
      if (left.contains(x, (y - height) * -1)) {
        controller.leftPressed(pointer);
      }

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

      if (jump.contains(x, (y - height) * -1)) {
        controller.jumpPressed(pointer);
      }

      return true;
    }
    return false;
  }
Exemple #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;
  }