Exemplo n.º 1
0
 public void win() {
   if (mEngine.isRunning()) {
     failSprite.setVisible(false);
     winSprite.setVisible(true);
     mMainScene.setChildScene(mResultScene, false, true, true);
     mEngine.stop();
   }
 }
Exemplo n.º 2
0
  @Override
  public boolean onMenuItemClicked(
      final MenuScene pMenuScene,
      final IMenuItem pMenuItem,
      final float pMenuItemLocalX,
      final float pMenuItemLocalY) {
    switch (pMenuItem.getID()) {
      case MENU_MUSIC:
        if (audioOptions.getBoolean("musicOn", true)) {
          audioEditor.putBoolean("musicOn", false);
          if (StartActivity.mMusic.isPlaying()) StartActivity.mMusic.pause();
        } else {
          audioEditor.putBoolean("musicOn", true);
          StartActivity.mMusic.resume();
        }
        audioEditor.commit();
        createOptionsMenuScene();
        mMainScene.clearChildScene();
        mMainScene.setChildScene(mOptionsMenuScene);
        return true;
      case MENU_EFFECTS:
        if (audioOptions.getBoolean("effectsOn", true)) {
          audioEditor.putBoolean("effectsOn", false);
        } else {
          audioEditor.putBoolean("effectsOn", true);
        }
        audioEditor.commit();
        createOptionsMenuScene();
        mMainScene.clearChildScene();
        mMainScene.setChildScene(mOptionsMenuScene);
        return true;
      case MENU_WAV:
        mMainScene.registerEntityModifier(
            new ScaleAtModifier(0.5f, 1.0f, 0.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2));
        mOptionsMenuScene.registerEntityModifier(
            new ScaleAtModifier(0.5f, 1.0f, 0.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2));
        mHandler.postDelayed(mLaunchWAVTask, 1000);
        return true;

      default:
        return false;
    }
  }
Exemplo n.º 3
0
  @Override
  public boolean onMenuItemClicked(
      final MenuScene pMenuScene,
      final IMenuItem pMenuItem,
      final float pMenuItemLocalX,
      final float pMenuItemLocalY) {
    switch (pMenuItem.getID()) {
      case MENU_MUSIC:
        if (isMusicOn) {
          isMusicOn = false;
        } else {
          isMusicOn = true;
        }
        createOptionsMenuScene();
        mMainScene.clearChildScene();
        mMainScene.setChildScene(mOptionsMenuScene);
        return true;
      case MENU_EFFECTS:
        if (isEffectsOn) {
          isEffectsOn = false;
        } else {
          isEffectsOn = true;
        }
        createOptionsMenuScene();
        mMainScene.clearChildScene();
        mMainScene.setChildScene(mOptionsMenuScene);
        return true;
      case MENU_WAV:
        mMainScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mOptionsMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mHandler.postDelayed(mLaunchWAVTask, 1000);
        return true;

      default:
        return false;
    }
  }
 @Override
 public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) {
   if (pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) {
     if (popupDisplayed) {
       /* Remove the menu and reset it. */
       this.mPopUpMenuScene.back();
       mMainScene.setChildScene(mStaticMenuScene);
       popupDisplayed = false;
     } else {
       /* Attach the menu. */
       this.mMainScene.setChildScene(this.mPopUpMenuScene, false, true, true);
       popupDisplayed = true;
     }
     return true;
   } else {
     return super.onKeyDown(pKeyCode, pEvent);
   }
 }
Exemplo n.º 5
0
  @Override
  public Scene onLoadScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    this.createOptionsMenuScene();

    /* Center the background on the camera. */
    final int centerX = (CAMERA_WIDTH - this.mMenuBackTextureRegion.getWidth()) / 2;
    final int centerY = (CAMERA_HEIGHT - this.mMenuBackTextureRegion.getHeight()) / 2;

    this.mMainScene = new Scene(1);
    /* Add the background and static menu */
    final Sprite menuBack = new Sprite(centerX, centerY, this.mMenuBackTextureRegion);
    mMainScene.getLastChild().attachChild(menuBack);
    mMainScene.setChildScene(mOptionsMenuScene);

    return this.mMainScene;
  }