Interface AppState

All Known Implementing Classes:
AbstractAppState, ArmatureDebugAppState, AudioListenerState, AWTComponentAppState, BaseAppState, BasicProfilerState, BulletAppState, BulletDebugAppState, ChaseCameraAppState, Cinematic, CompositeAppState, ConstantVerifierState, DebugKeysAppState, DetailedProfilerState, EnvironmentCamera, FlyCamAppState, LightsDebugState, MaterialDebugAppState, ResetStatsState, RootNodeAppState, ScreenshotAppState, StatsAppState, VideoRecorderAppState, VRAppState

public interface AppState
AppState represents continuously executing code inside the main loop. An AppState can track when it is attached to the AppStateManager or when it is detached. AppStates are initialized in the render thread, upon a call to initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application) and are de-initialized upon a call to cleanup(). Implementations should return the correct value with a call to isInitialized() as specified above.
  • If a detached AppState is attached then initialize() will be called on the following render pass.
  • If an attached AppState is detached then cleanup() will be called on the following render pass.
  • If you attach an already-attached AppState then the second attach is a no-op and will return false.
  • If you both attach and detach an AppState within one frame then neither initialize() or cleanup() will be called, although if either is called both will be.
  • If you both detach and then re-attach an AppState within one frame then on the next update pass its cleanup() and initialize() methods will be called in that order.
  • Method Details

    • initialize

      void initialize(AppStateManager stateManager, Application app)
      Called by AppStateManager when transitioning this AppState from initializing to running.
      This will happen on the next iteration through the update loop after AppStateManager.attach(com.jme3.app.state.AppState) was called.

      AppStateManager will call this only from the update loop inside the rendering thread. This means is it safe to modify the scene graph from this method.

      Parameters:
      stateManager - The state manager
      app - The application
    • isInitialized

      boolean isInitialized()
      Returns:
      True if initialize() was called on the state, false otherwise.
    • getId

      String getId()
      Returns the unique ID for this AppState or null if it has no unique ID.
      Returns:
      the ID, or null if none
    • setEnabled

      void setEnabled(boolean active)
      Enable or disable the functionality of the AppState. The effect of this call depends on implementation. An AppState starts as being enabled by default. A disabled AppStates does not get calls to update(float), render(RenderManager), or postRender() from its AppStateManager.
      Parameters:
      active - activate the AppState or not.
    • isEnabled

      boolean isEnabled()
      Returns:
      True if the AppState is enabled, false otherwise.
      See Also:
    • stateAttached

      void stateAttached(AppStateManager stateManager)
      Called by AppStateManager.attach(com.jme3.app.state.AppState) when transitioning this AppState from detached to initializing.

      There is no assumption about the thread from which this function is called, therefore it is unsafe to modify the scene graph from this method. Please use initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application) instead.

      Parameters:
      stateManager - State manager to which the state was attached to.
    • stateDetached

      void stateDetached(AppStateManager stateManager)
      Called by AppStateManager.detach(com.jme3.app.state.AppState) when transitioning this AppState from running to terminating.

      There is no assumption about the thread from which this function is called, therefore it is unsafe to modify the scene graph from this method. Please use cleanup() instead.

      Parameters:
      stateManager - The state manager from which the state was detached from.
    • update

      void update(float tpf)
      Called to update the AppState. This method will be called every render pass if the AppState is both attached and enabled.
      Parameters:
      tpf - Time since the last call to update(), in seconds.
    • render

      void render(RenderManager rm)
      Render the state. This method will be called every render pass if the AppState is both attached and enabled.
      Parameters:
      rm - RenderManager
    • postRender

      void postRender()
      Called after all rendering commands are flushed. This method will be called every render pass if the AppState is both attached and enabled.
    • cleanup

      void cleanup()
      Called by AppStateManager when transitioning this AppState from terminating to detached. This method is called the following render pass after the AppState has been detached and is always called once and only once for each time initialize() is called. Either when the AppState is detached or when the application terminates (if it terminates normally).