Пример #1
0
  @Override
  public void onSolvedGame() {

    restartButton.setVisible(false);

    Level level = gameService.getLevel();
    final LevelResult levelResult = levelService.calculateLevelResult(level);
    levelService.persistLevelResult(levelResult);

    int nextLevelId = level.getId() + 1;
    levelService.unlockLevel(nextLevelId);
    this.leaveScene = true;
    engine.registerUpdateHandler(
        new TimerHandler(
            1.5f,
            new ITimerCallback() {

              @Override
              public void onTimePassed(TimerHandler pTimerHandler) {

                engine.unregisterUpdateHandler(pTimerHandler);
                storyService.loadScoreScreen(levelResult);
              }
            }));
  }
Пример #2
0
  private void createButton() {
    // Button Exit
    btn_exit =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            GameActivity.getCameraHeight() / 4,
            m_resource_manager.m_button_region[Constant.BTN_EXIT],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pTouchEvent.isActionDown()) {
              pauseGame();
              m_activity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      new DialogExit(m_activity).show();
                    }
                  });
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    registerTouchArea(btn_exit);
    btn_exit.setScale(0.75f);
    attachChild(btn_exit);

    // Button sound on

    btn_sound_on =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            GameActivity.getCameraHeight() / 2,
            m_resource_manager.m_button_region[Constant.BTN_SOUND_ON],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {

            if (pTouchEvent.isActionDown()) {
              this.setVisible(false);
              sound_on = false;
              btn_sound_off.setVisible(true);
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_sound_on.setScale(0.75f);
    registerTouchArea(btn_sound_on);
    attachChild(btn_sound_on);
    // Button sound off
    btn_sound_off =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            GameActivity.getCameraHeight() / 2,
            m_resource_manager.m_button_region[Constant.BTN_SOUND_OFF],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pTouchEvent.isActionDown()) {
              this.setVisible(false);
              sound_on = true;
              btn_sound_on.setVisible(true);
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_sound_off.setScale(0.75f);
    btn_sound_off.setVisible(false);
    registerTouchArea(btn_sound_off);
    attachChild(btn_sound_off);
    // Button Settings
    btn_settings =
        new ButtonSprite(
            GameActivity.getCameraWidth() - shift_col / 3,
            3 * GameActivity.getCameraHeight() / 4,
            m_resource_manager.m_button_region[Constant.BTN_SETTINGS],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            pauseGame();
            if (pTouchEvent.isActionDown()) {
              //
              m_activity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      new DialogLevel(m_activity).show();
                    }
                  });
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_settings.setScale(0.75f);
    registerTouchArea(btn_settings);
    attachChild(btn_settings);
    // Button Play
    btn_play =
        new ButtonSprite(
            shift_col / 3,
            2 * GameActivity.getCameraHeight() / 5,
            m_resource_manager.m_button_region[Constant.BTN_PLAY],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            pauseGame();
            if (pTouchEvent.isActionDown()) {
              //					this.setVisible(false);
              //	btn_pause.setVisible(true);
              m_activity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      new DialogPause(m_activity).show();
                    }
                  });
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_play.setScale(0.75f);
    registerTouchArea(btn_play);

    attachChild(btn_play);

    //		btn_pause = new ButtonSprite(shift_col/3 , 2*GameActivity.getCameraHeight()/5,
    // m_resource_manager.m_button_region[Constant.BTN_PAUSE], m_vbom){
    //			@Override
    //			public boolean onAreaTouched(TouchEvent pTouchEvent, float pTouchAreaLocalX, float
    // pTouchAreaLocalY) {
    //				if(pTouchEvent.isActionDown()) {
    //					this.setVisible(false);
    //					btn_play.setVisible(true);
    //					resumeGame();
    //
    //				}
    //				return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
    //			}
    //
    //		};
    //		btn_pause.setScale(0.75f);
    //		registerTouchArea(btn_pause);
    //		btn_pause.setVisible(false);
    //		attachChild(btn_pause);

    // Button restart
    btn_restart =
        new ButtonSprite(
            shift_col / 3,
            GameActivity.getCameraHeight() / 5,
            m_resource_manager.m_button_region[Constant.BTN_RESTART],
            m_vbom) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pTouchEvent.isActionDown()) {
              restartGame();
            }
            return super.onAreaTouched(pTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
          }
        };
    btn_restart.setScale(0.75f);
    registerTouchArea(btn_restart);
    attachChild(btn_restart);
  }