Package com.jme3.app.state
Class AppStateManager
java.lang.Object
com.jme3.app.state.AppStateManager
The 
When an
AppStateManager holds a list of AppStates which
 it will update and render.When an
AppState is attached or detached, the
 AppState.stateAttached(com.jme3.app.state.AppStateManager) and
 AppState.stateDetached(com.jme3.app.state.AppStateManager) methods
 will be called respectively.
 The lifecycle for an attached AppState is as follows:
- stateAttached() : called when the state is attached on the thread on which the state was attached.
- initialize() : called ONCE on the render thread at the beginning of the next AppStateManager.update().
- stateDetached() : called when the state is detached on the thread on which the state was detached. This is not necessarily on the render thread and it is not necessarily safe to modify the scene graph, etc..
- cleanup() : called ONCE on the render thread at the beginning of the next update after the state has been detached or when the application is terminating.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanAttach a state to the AppStateManager, the same state cannot be attached twice.voidAttaches many state to the AppStateManager in a way that is guaranteed that they will all get initialized before any of their updates are run.voidAttaches many state to the AppStateManager in a way that is guaranteed that they will all get initialized before any of their updates are run.voidcleanup()Calls cleanup on attached states, do not call directly.booleanDetaches the state from the AppStateManager.Returns the Application to which this AppStateManager belongs.protected AppState[]<T extends AppState>
 TReturns the first state that is an instance of subclass of the specified class.<T extends AppState>
 TReturns the first state that is an instance of subclass of the specified class.<T extends AppState>
 TReturns the state associated with the specified ID at the time it was attached or null if not state was attached with that ID.protected AppState[]protected AppState[]booleanCheck if a state is attached or not.booleanReturns true if there is currently a state associated with the specified ID.protected voidvoidCalls render for all attached and initialized states, do not call directly.voidrender(RenderManager rm) Calls render for all attached and initialized states, do not call directly.<T extends AppState>
 TstateForId(String id, Class<T> stateClass) Returns the state associated with the specified ID at the time it was attached or throws an IllegalArgumentException if the ID was not found.protected voidvoidupdate(float tpf) Calls update for attached states, do not call directly.
- 
Constructor Details- 
AppStateManager
 
- 
- 
Method Details- 
getApplicationReturns the Application to which this AppStateManager belongs.- Returns:
- the pre-existing instance
 
- 
getInitializing
- 
getTerminating
- 
getStates
- 
attachAttach a state to the AppStateManager, the same state cannot be attached twice. Throws an IllegalArgumentException if the state has an ID and that ID has already been associated with another AppState.- Parameters:
- state- The state to attach
- Returns:
- True if the state was successfully attached, false if the state was already attached.
 
- 
attachAllAttaches many state to the AppStateManager in a way that is guaranteed that they will all get initialized before any of their updates are run. The same state cannot be attached twice and will be ignored.- Parameters:
- states- The states to attach
 
- 
attachAllAttaches many state to the AppStateManager in a way that is guaranteed that they will all get initialized before any of their updates are run. The same state cannot be attached twice and will be ignored.- Parameters:
- states- The states to attach
 
- 
detachDetaches the state from the AppStateManager.- Parameters:
- state- The state to detach
- Returns:
- True if the state was detached successfully, false if the state was not attached in the first place.
 
- 
hasStateCheck if a state is attached or not.- Parameters:
- state- The state to check
- Returns:
- True if the state is currently attached to this AppStateManager.
- See Also:
 
- 
getStateReturns the first state that is an instance of subclass of the specified class.- Type Parameters:
- T- the desired type of AppState
- Parameters:
- stateClass- the desired type of AppState
- Returns:
- First attached state that is an instance of stateClass
 
- 
getStateReturns the first state that is an instance of subclass of the specified class.- Type Parameters:
- T- the desired type of AppState
- Parameters:
- stateClass- the desired type of AppState
- failOnMiss- true to throw an exception, false to return null
- Returns:
- First attached state that is an instance of stateClass. If failOnMiss is true then an IllegalArgumentException is thrown if the state is not attached.
 
- 
getStateReturns the state associated with the specified ID at the time it was attached or null if not state was attached with that ID.- Type Parameters:
- T- the desired type of AppState
- Parameters:
- id- the AppState ID
- stateClass- the desired type of AppState
- Returns:
- the pre-existing instance, or null if not found
 
- 
hasStateReturns true if there is currently a state associated with the specified ID.- Parameters:
- id- the AppState ID
- Returns:
- true if found, otherwise false
 
- 
stateForIdReturns the state associated with the specified ID at the time it was attached or throws an IllegalArgumentException if the ID was not found.- Type Parameters:
- T- the desired type of AppState
- Parameters:
- id- the AppState ID
- stateClass- the desired type of AppState
- Returns:
- the pre-existing instance (not null)
 
- 
initializePendingprotected void initializePending()
- 
terminatePendingprotected void terminatePending()
- 
updatepublic void update(float tpf) Calls update for attached states, do not call directly.- Parameters:
- tpf- Time per frame.
 
- 
renderCalls render for all attached and initialized states, do not call directly.- Parameters:
- rm- The RenderManager
 
- 
postRenderpublic void postRender()Calls render for all attached and initialized states, do not call directly.
- 
cleanuppublic void cleanup()Calls cleanup on attached states, do not call directly.
 
-