示例#1
0
  // See if a button was clicked
  @Override
  public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    screenX = scaleX(screenX);
    screenY = scaleY(screenY);

    if (mWorld.isMenu()) {
      start.isTouchDown(screenX, screenY);
    } else if (mWorld.isRunning() || mWorld.isChoice()) {
      if (!add.isTouchDown(screenX, screenY)
          && !upLeft.isTouchDown(screenX, screenY)
          && !up.isTouchDown(screenX, screenY)
          && !upRight.isTouchDown(screenX, screenY)
          && !left.isTouchDown(screenX, screenY)
          && !right.isTouchDown(screenX, screenY)
          && !downLeft.isTouchDown(screenX, screenY)
          && !downRight.isTouchDown(screenX, screenY)
          && !down.isTouchDown(screenX, screenY)
          && !sUpLeft.isTouchDown(screenX, screenY)
          && !sUp.isTouchDown(screenX, screenY)
          && !sUpRight.isTouchDown(screenX, screenY)
          && !sLeft.isTouchDown(screenX, screenY)
          && !sRight.isTouchDown(screenX, screenY)
          && !sDownLeft.isTouchDown(screenX, screenY)
          && !sDownRight.isTouchDown(screenX, screenY)
          && !sDown.isTouchDown(screenX, screenY)
          && !swap.isTouchDown(screenX, screenY)) {
        mWorld.ready(false);
      }
    } else if (mWorld.isGameOver() || mWorld.isHighScore()) {
      mWorld.restart();
    }

    return true;
  }
示例#2
0
  // See if button was meant to be clicked
  @Override
  public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    screenX = scaleX(screenX);
    screenY = scaleY(screenY);

    if (mWorld.isMenu()) {
      if (start.isTouchUp(screenX, screenY)) {
        mWorld.ready(true);
        return true;
      }
    } else if (mWorld.isRunning()) {
      if (add.isTouchUp(screenX, screenY)) {
        mWorld.choice();
      }
    } else if (mWorld.isChoice()) {
      if (upLeft.isTouchUp(screenX, screenY)) {
        setMove("upLeft");
      }
      if (up.isTouchUp(screenX, screenY)) {
        setMove("up");
      }
      if (upRight.isTouchUp(screenX, screenY)) {
        setMove("upRight");
      }
      if (down.isTouchUp(screenX, screenY)) {
        setMove("down");
      }
      if (downLeft.isTouchUp(screenX, screenY)) {
        setMove("downLeft");
      }
      if (downRight.isTouchUp(screenX, screenY)) {
        setMove("downRight");
      }
      if (left.isTouchUp(screenX, screenY)) {
        setMove("left");
      }
      if (right.isTouchUp(screenX, screenY)) {
        setMove("right");
      }

      if (sUpLeft.isTouchUp(screenX, screenY)) {
        setMove("sUpLeft");
      }
      if (sUp.isTouchUp(screenX, screenY)) {
        setMove("sUp");
      }
      if (sUpRight.isTouchUp(screenX, screenY)) {
        setMove("sUpRight");
      }
      if (sDown.isTouchUp(screenX, screenY)) {
        setMove("sDown");
      }
      if (sDownLeft.isTouchUp(screenX, screenY)) {
        setMove("sDownLeft");
      }
      if (sDownRight.isTouchUp(screenX, screenY)) {
        setMove("sDownRight");
      }
      if (sLeft.isTouchUp(screenX, screenY)) {
        setMove("sLeft");
      }
      if (sRight.isTouchUp(screenX, screenY)) {
        setMove("sRight");
      }

      if (swap.isTouchUp(screenX, screenY)) {
        if (mWorld.getMoves()[0] == "add" || mWorld.getMoves()[1] == "add") {
          System.out.println("Not enough tiles available to swap");
        } else {
          System.out.println("Swapped a tile");
          swapMove();
          setMove("swap");
        }
      }
      for (int i = 0; i < 3; i++) {
        System.out.println("Move " + i + " is " + mWorld.getMoves()[i]);
      }
      System.out.println("Current turn is: " + mWorld.getTurn());
    }
    return false;
  }