Class AbstractAppState

java.lang.Object
com.jme3.app.state.AbstractAppState
All Implemented Interfaces:
AppState
Direct Known Subclasses:
AWTComponentAppState, BulletAppState, BulletDebugAppState, ChaseCameraAppState, DebugKeysAppState, FlyCamAppState, MaterialDebugAppState, ResetStatsState, RootNodeAppState, ScreenshotAppState, StatsAppState, VideoRecorderAppState, VRAppState

public abstract class AbstractAppState extends Object implements AppState
AbstractAppState implements some common methods that make creation of AppStates easier.
See Also:
  • Field Details

  • Constructor Details

    • AbstractAppState

      protected AbstractAppState()
    • AbstractAppState

      protected AbstractAppState(String id)
  • Method Details

    • initialize

      public void initialize(AppStateManager stateManager, Application app)
      Description copied from interface: AppState
      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.

      Specified by:
      initialize in interface AppState
      Parameters:
      stateManager - The state manager
      app - The application
    • isInitialized

      public boolean isInitialized()
      Specified by:
      isInitialized in interface AppState
      Returns:
      True if initialize() was called on the state, false otherwise.
    • setId

      protected void setId(String id)
      Sets the unique ID of this app state. Note: that setting this while an app state is attached to the state manager will have no effect on ID-based lookups.
      Parameters:
      id - the desired ID
    • getId

      public String getId()
      Description copied from interface: AppState
      Returns the unique ID for this AppState or null if it has no unique ID.
      Specified by:
      getId in interface AppState
      Returns:
      the ID, or null if none
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: AppState
      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 AppState.update(float), AppState.render(RenderManager), or AppState.postRender() from its AppStateManager.
      Specified by:
      setEnabled in interface AppState
      Parameters:
      enabled - activate the AppState or not.
    • isEnabled

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

      public void stateAttached(AppStateManager stateManager)
      Description copied from interface: AppState
      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 AppState.initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application) instead.

      Specified by:
      stateAttached in interface AppState
      Parameters:
      stateManager - State manager to which the state was attached to.
    • stateDetached

      public void stateDetached(AppStateManager stateManager)
      Description copied from interface: AppState
      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 AppState.cleanup() instead.

      Specified by:
      stateDetached in interface AppState
      Parameters:
      stateManager - The state manager from which the state was detached from.
    • update

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

      public void render(RenderManager rm)
      Description copied from interface: AppState
      Render the state. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      render in interface AppState
      Parameters:
      rm - RenderManager
    • postRender

      public void postRender()
      Description copied from interface: AppState
      Called after all rendering commands are flushed. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      postRender in interface AppState
    • cleanup

      public void cleanup()
      Description copied from interface: AppState
      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).
      Specified by:
      cleanup in interface AppState