Example #1
0
 public void renderGamePause() {
   batcher.draw(Assets.gamePauseBgRegion, 0, 0);
   pauseBackButton.draw(batcher);
   pauseStartButton.draw(batcher);
   pauseRestartButton.draw(batcher);
   if (game.soundState) {
     pauseSoundButton.draw(batcher);
   } else {
     pauseQuietButton.draw(batcher);
   }
 }
Example #2
0
  public void updateGamePause() {
    unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
    if (Gdx.input.justTouched()) {
      if (GameUtils.pointInRectangle(pauseBounds, touchPoint.x, touchPoint.y) && !isPause) {
        Assets.playSound(Assets.buttonClickSound, true);
        isPause = true;
        return;
      }
    }

    if (gestureDetector.isTouchOn()) {
      System.out.println("touch xy: " + touchPoint.x + " " + touchPoint.y);
      pauseBackButton.isPressed = false;
      pauseStartButton.isPressed = false;
      pauseRestartButton.isPressed = false;
      pauseQuietButton.isPressed = false;
      pauseSoundButton.isPressed = false;
      if (isPause
          && GameUtils.pointInRectangle(pauseBackButton.rectRegion, touchPoint.x, touchPoint.y)) {
        System.out.println("pauseBackButton touch");
        Assets.playSound(Assets.buttonClickSound, game.soundState);
        game.setScreen(new ClothAndLevelScreen(game));
      } else if (isPause
          && GameUtils.pointInRectangle(pauseStartButton.rectRegion, touchPoint.x, touchPoint.y)) {
        System.out.println("pauseStartButton touch");
        Assets.playSound(Assets.buttonClickSound, game.soundState);
        isPause = false;
      } else if (isPause
          && GameUtils.pointInRectangle(
              pauseRestartButton.rectRegion, touchPoint.x, touchPoint.y)) {
        System.out.println("pauseRestartButton touch");
        Assets.playSound(Assets.buttonClickSound, game.soundState);
        game.setScreen(new GameScreen(game, game.mapTheme, game.level, game.kiteType));
      } else if (isTreasure
          && GameUtils.pointInRectangle(treasureBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.buttonClickSound, true);
        isTreasure = false;
        isDialog = true;
        // ×îÖÕ¹Ø
        //				if(game.mapTheme.equals("space") && game.level == 3){
        //					isFinal = true;
        //					return;
        //				}
        int theme = GameUtils.getMapTheme(game.mapTheme) + 1;
        if (theme >= 4) {
          isFinal = true;
          return;
        }
        ClothAndLevelScreen screen = new ClothAndLevelScreen(game);
        screen.currentTheme = theme;
        game.setScreen(screen);
        return;
      } else if (isFinal && GameUtils.pointInRectangle(finalBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.buttonClickSound, true);
        isFinal = false;
        game.setScreen(new ClothAndLevelScreen(game));
      } else if (isPause
          && GameUtils.pointInRectangle(pauseSoundButton.rectRegion, touchPoint.x, touchPoint.y)) {
        System.out.println("pauseSoundButton touch");
        Assets.playSound(Assets.buttonClickSound, game.soundState);
        if (!game.soundState) {
          game.soundState = true;
          Assets.playMusic(bgMusic, game.soundState);
        } else {
          game.soundState = false;
          Assets.playMusic(bgMusic, game.soundState);
        }
      }
    } else if (gestureDetector.isTouchDown()) {
      System.out.println("touch xy: " + touchPoint.x + " " + touchPoint.y);
      pauseBackButton.isPressed =
          GameUtils.pointInRectangle(pauseBackButton.rectRegion, touchPoint.x, touchPoint.y);
      pauseStartButton.isPressed =
          GameUtils.pointInRectangle(pauseStartButton.rectRegion, touchPoint.x, touchPoint.y);
      pauseRestartButton.isPressed =
          GameUtils.pointInRectangle(pauseRestartButton.rectRegion, touchPoint.x, touchPoint.y);
      if (game.soundState)
        pauseSoundButton.isPressed =
            GameUtils.pointInRectangle(pauseSoundButton.rectRegion, touchPoint.x, touchPoint.y);
      else
        pauseQuietButton.isPressed =
            GameUtils.pointInRectangle(pauseQuietButton.rectRegion, touchPoint.x, touchPoint.y);
    }
  }