Class CompositeAppState

java.lang.Object
com.jme3.app.state.BaseAppState
com.jme3.app.state.CompositeAppState
All Implemented Interfaces:
AppState

public class CompositeAppState extends BaseAppState
An AppState that manages a set of child app states, making sure they are attached/detached and optional enabled/disabled with the parent state.
  • Constructor Details

    • CompositeAppState

      public CompositeAppState(AppState... states)
  • Method Details

    • addChild

      protected <T extends AppState> T addChild(T state)
    • addChild

      protected <T extends AppState> T addChild(T state, boolean overrideEnable)
    • removeChild

      protected void removeChild(AppState state)
    • getChild

      protected <T extends AppState> T getChild(Class<T> stateType)
    • clearChildren

      protected void clearChildren()
    • 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
      Overrides:
      stateAttached in class BaseAppState
      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
      Overrides:
      stateDetached in class BaseAppState
      Parameters:
      stateManager - The state manager from which the state was detached from.
    • setChildrenEnabled

      protected void setChildrenEnabled(boolean b)
    • setOverrideEnabled

      public void setOverrideEnabled(AppState state, boolean override)
      Overrides the automatic synching of a child's enabled state. When override is true, a child will remember its old state when the parent's enabled state is false so that when the parent is re-enabled the child can resume its previous enabled state. This is useful for the cases where a child may want to be disabled independent of the parent... and then not automatically become enabled just because the parent does. Currently, the parent's disabled state always disables the children, too. Override is about remembering the child's state before that happened and restoring it when the 'family' is enabled again as a whole.
    • initialize

      protected void initialize(Application app)
      Description copied from class: BaseAppState
      Called during initialization once the app state is attached and before onEnable() is called.
      Specified by:
      initialize in class BaseAppState
      Parameters:
      app - the application
    • cleanup

      protected void cleanup(Application app)
      Description copied from class: BaseAppState
      Called after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.
      Specified by:
      cleanup in class BaseAppState
      Parameters:
      app - the application
    • onEnable

      protected void onEnable()
      Description copied from class: BaseAppState
      Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.
      Specified by:
      onEnable in class BaseAppState
    • onDisable

      protected void onDisable()
      Description copied from class: BaseAppState
      Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.
      Specified by:
      onDisable in class BaseAppState