Ejemplo n.º 1
0
  /**
   * This method will add to the stage a confirmation dialog asking the user whether to end the game
   * or not. If the user answers YES to that dialog, the game will end.
   */
  private void showLeaveDialog() {
    ConfirmDialog dialog =
        new ConfirmDialog(
            game.getSkin(),
            game.getLocale().get("game.leave"),
            game.getLocale().get("core.yes"),
            game.getLocale().get("core.no"));
    dialog.setCallback(
        new ConfirmDialog.ConfirmCallback() {
          @Override
          public void ok() {
            // The user wants to leave the game.
            game.player.playSound(SoundCode.SUCCESS);
            askingLeave = false;
            onTimeOut();
          }

          @Override
          public void cancel() {
            // The user wants to resume the game.
            game.player.playSound(SoundCode.FAIL);
            askingLeave = false;
            resumeGame();
          }
        });

    dialog.show(getStage());
    askingLeave = true;
  }
Ejemplo n.º 2
0
  private void showPauseDialog() {
    ConfirmDialog dialog =
        new ConfirmDialog(
            game.getSkin(),
            game.getLocale().get("game.paused"),
            game.getLocale().get("game.continue"),
            game.getLocale().get("game.leaveGame"));
    dialog.setCallback(
        new ConfirmDialog.ConfirmCallback() {
          @Override
          public void ok() {
            // Continue
            game.player.playSound(SoundCode.SELECT);
            askingLeave = false;
            resumeGame();
          }

          @Override
          public void cancel() {
            // Leave
            game.player.playSound(SoundCode.SELECT);
            showLeaveDialog();
          }
        });

    dialog.show(getStage());
    askingLeave = true;
  }