コード例 #1
0
 /**
  * Detaches and disposes all Entities that does not have the tag <em>TAG_PRESERVE</em> ({@value
  * #TAG_PRESERVE}) in the HUD and in this scene.
  */
 public void detachAndDisposeNonPreservedEntities() {
   EnvironmentVars.MAIN_CONTEXT.runOnUpdateThread(
       new Runnable() {
         @Override
         public void run() {
           SessionScene.this.detachAndDisposeEntities(true);
         }
       });
 }
コード例 #2
0
  /** Closes this game session and returns to the main menu. */
  public void toMainMenu(final String optionalMessage) {

    EnvironmentVars.MAIN_CONTEXT.runOnUpdateThread(
        new Runnable() {
          @Override
          public void run() {
            for (final BaseAudioEntity audio : EnvironmentVars.MAIN_CONTEXT.getAudioRegistered()) {
              audio.pause();
              EnvironmentVars.MAIN_CONTEXT.unregisterSound(audio);
            }

            ResourceManager.btScrapPartsBig.unload();

            SessionScene.this.setIgnoreUpdate(false);
            SessionScene.this.detachAndDisposeEntities(false);

            SessionScene.HUD.setOnSceneTouchListener(null);

            EnvironmentVars.MAIN_CONTEXT
                .getCamera()
                .setCenter(
                    EnvironmentVars.MAIN_CONTEXT.width() / 2f,
                    EnvironmentVars.MAIN_CONTEXT.height() / 2f);

            final MainMenuScene SCENE =
                new MainMenuScene() {
                  @Override
                  public void init() {
                    super.init();
                    if (!optionalMessage.contentEquals("")) this.showDialog(optionalMessage);
                  }
                };

            EnvironmentVars.MAIN_CONTEXT.getEngine().setScene(SCENE);
            if (!SessionScene.this.isDisposed()) SessionScene.this.dispose();
            System.gc();
            SCENE.init();
          }
        });
  }