/**
  * The update loop, do not call manually!
  *
  * <p>Invoked automatically by SimpleApplication.
  *
  * @param tpf Time-per-frame
  */
 @Override
 public void update(float tpf) {
   if (isEnabled()) {
     // do the following while game is RUNNING // modify scene graph...
     input.update(tpf, this.isEnabled());
     game.update(tpf);
     guiView.update(tpf);
   }
   // do something in an else statement while game is PAUSED, e.g. play an
   // idle animation.
   // ...
 }
  /**
   * Initializes the state.
   *
   * <p>Do not manually call this method! This method is invoked automatically by SimpleApplication.
   *
   * @param stateManager SimpleApplication's stateManager
   * @param app A class extending SimpleApplication
   */
  @Override
  public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    this.app = (SimpleApplication) app; // cast to a more specific class
    // init stuff that is independent of whether state is PAUSED or RUNNING
    // // modify scene graph...
    initializeImages();
    GameView view = new GameView(this.app, game);
    guiView = new GameGUIView(nifty, game);

    input = new InputController(this.app, game, view);
    new InGameGUIController(input, nifty, guiView, game);

    initializeCamera();
    // Initialize view last, after model and controller, since its
    // initialization is dependent on the other's.
    view.initialize();
    guiView.initialize();
    input.addListener(guiView);
  }