예제 #1
0
  @Override
  public void present(float deltaTime) {
    GLCommon gl = Gdx.gl;
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    camera.update();

    worldRender.render(deltaTime);
    if (isTreasure) {
      batcher.begin();
      renderTreasure(treasureType);
      if (isTreasureSound) {
        Assets.playSound(Assets.treasureSound, game.soundState);
        isTreasureSound = false;
      }
      batcher.end();
    } else if (isFinal) {
      batcher.begin();
      renderFinal();
      batcher.end();
    } else {
      if (isPause && !isDialog) {
        batcher.begin();
        renderGamePause();
        batcher.end();
      }
    }
    if ((isPause || !game.soundState) && bgMusic.isPlaying()) {
      bgMusic.pause();
    } else if (!isPause && !bgMusic.isPlaying() && game.soundState) {
      Assets.playMusic(bgMusic, game.soundState);
    }
  }
예제 #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);
    }
  }