Beispiel #1
0
  // to change the current main scene
  public void setCurrentScene(Scene scene) {
    Log.i("GAME", "Scene : " + scene.getClass());

    if (mSceneType == SceneType.GAME) {
      mHUD.setVisible(true);
      mCamera.setZoomFactor(0.5f);
      if (!mMusicLoop.isPlaying()) mMusicLoop.play();
    } else {
      mHUD.setVisible(false);
      mCamera.setZoomFactor(1f);
    }

    mCurrentScene = scene;
    getEngine().setScene(mCurrentScene);
  }
Beispiel #2
0
 @Override
 // Gestion du retour
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
     switch (mSceneType) {
       case LOADING:
         System.exit(0);
         break;
       case MENU:
         System.exit(0);
         break;
       case OPTIONS:
         this.setSceneType(SceneType.MENU);
         this.setCurrentScene(mMenu);
         break;
       case GAME:
         this.setSceneType(SceneType.MENU);
         this.setCurrentScene(mMenu);
         if (mMusicLoop.isPlaying()) mMusicLoop.pause();
         break;
     }
   }
   return false;
 }
 public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException {
   SceneManager.getInstance().createSplashScene(pOnCreateSceneCallback);
   GameActivity.myMusic.play();
   myMusic.setLooping(true);
 }
  protected void showFirstWave() {
    if (this.rsRoundSystem.getStartRound() != 1) return;

    // @formatter:off
    this.sFirstWave =
        new Sprite(
            (EnvironmentVars.MAIN_CONTEXT.width() - HudRegions.region_wave_1[0].getWidth()) / 2f,
            (EnvironmentVars.MAIN_CONTEXT.height() - HudRegions.region_wave_1[0].getHeight()) / 2f,
            HudRegions.region_wave_1[0],
            EnvironmentVars.MAIN_CONTEXT.getVertexBufferObjectManager());
    this.sFirstWave.setScale(4f);

    this.sFirstWaveSub =
        new Sprite(
            (EnvironmentVars.MAIN_CONTEXT.width() - HudRegions.region_wave_1[1].getWidth()) / 2f,
            this.sFirstWave.getY() + this.sFirstWave.getHeightScaled() + 4f,
            HudRegions.region_wave_1[1],
            EnvironmentVars.MAIN_CONTEXT.getVertexBufferObjectManager()) {
          @Override
          public void dispose() {
            ResourceManager.btWave1.unload();
            super.dispose();
          }
        };
    this.sFirstWaveSub.setScale(1.5f);
    // @formatter:on

    final Music FIRST_WAVE_MUSIC = ResourceManager.mFirstWave;
    EnvironmentVars.MAIN_CONTEXT.registerSound(FIRST_WAVE_MUSIC);
    FIRST_WAVE_MUSIC.seekTo(0);
    FIRST_WAVE_MUSIC.play();

    SessionScene.HUD.attachChild(SessionScene.this.sFirstWave);
    SessionScene.HUD.attachChild(SessionScene.this.sFirstWaveSub);

    ResourceManager.btWave1.load();

    final DelayModifier DELAY_LIFETIME =
        new DelayModifier(3f) {
          @Override
          protected void onModifierFinished(IEntity pItem) {
            super.onModifierFinished(pItem);

            SessionScene.this.rsRoundSystem.start();
            final FlashUpdateHandler FLASH = new FlashUpdateHandler(0.05f, 2);

            FLASH.runOnSwitch(
                new Runnable() {
                  @Override
                  public void run() {
                    final boolean VISIBLE = SessionScene.this.sFirstWave.isVisible();
                    SessionScene.this.sFirstWave.setVisible(!VISIBLE);
                  }
                });

            FLASH.runOnFinish(
                new Runnable() {
                  @Override
                  public void run() {
                    SessionScene.this.unregisterUpdateHandler(FLASH);
                    SessionScene.this.sFirstWave.setVisible(true);

                    EntityUtils.animateEntity(
                        SessionScene.this.sFirstWave,
                        0.25f,
                        EntityUtils.ANIMATION_JUMP_OUT_MEDIUM_INTESTIVITY,
                        EaseLinear.getInstance(),
                        EntityUtils.getDetachDisposeListener());

                    EntityUtils.animateEntity(
                        SessionScene.this.sFirstWaveSub,
                        1f,
                        EntityUtils.ANIMATION_FADE_OUT,
                        EaseCubicInOut.getInstance(),
                        EntityUtils.getDetachDisposeListener());
                  }
                });
            SessionScene.this.registerUpdateHandler(FLASH);
          }
        };
    DELAY_LIFETIME.setAutoUnregisterWhenFinished(true);
    this.registerEntityModifier(DELAY_LIFETIME);

    EntityUtils.animateEntity(this.sFirstWave, 1f, EntityUtils.ANIMATION_FADE_IN);
    EntityUtils.animateEntity(this.sFirstWaveSub, 1f, EntityUtils.ANIMATION_FADE_IN);
  }