public class AppStateManager
extends java.lang.Object
AppStateManager
holds a list of AppState
s which
it will update and render.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:
Constructor and Description |
---|
AppStateManager(Application app) |
Modifier and Type | Method and Description |
---|---|
boolean |
attach(AppState state)
Attach a state to the AppStateManager, the same state cannot be attached
twice.
|
void |
attachAll(AppState... states)
Attaches many state to the AppStateManager in a way that is guaranteed
that they will all get initialized before any of their updates are run.
|
void |
attachAll(java.lang.Iterable<AppState> states)
Attaches many state to the AppStateManager in a way that is guaranteed
that they will all get initialized before any of their updates are run.
|
void |
cleanup()
Calls cleanup on attached states, do not call directly.
|
boolean |
detach(AppState state)
Detaches the state from the AppStateManager.
|
Application |
getApplication()
Returns the Application to which this AppStateManager belongs.
|
protected AppState[] |
getInitializing() |
<T extends AppState> |
getState(java.lang.Class<T> stateClass)
Returns the first state that is an instance of subclass of the specified class.
|
<T extends AppState> |
getState(java.lang.Class<T> stateClass,
boolean failOnMiss)
Returns the first state that is an instance of subclass of the specified class.
|
<T extends AppState> |
getState(java.lang.String id,
java.lang.Class<T> stateClass)
Returns 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[] |
getStates() |
protected AppState[] |
getTerminating() |
boolean |
hasState(AppState state)
Check if a state is attached or not.
|
boolean |
hasState(java.lang.String id)
Returns true if there is currently a state associated with the specified
ID.
|
protected void |
initializePending() |
void |
postRender()
Calls render for all attached and initialized states, do not call directly.
|
void |
render(RenderManager rm)
Calls render for all attached and initialized states, do not call directly.
|
<T extends AppState> |
stateForId(java.lang.String id,
java.lang.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 void |
terminatePending() |
void |
update(float tpf)
Calls update for attached states, do not call directly.
|
public AppStateManager(Application app)
public Application getApplication()
protected AppState[] getInitializing()
protected AppState[] getTerminating()
protected AppState[] getStates()
public boolean attach(AppState state)
state
- The state to attachpublic void attachAll(AppState... states)
states
- The states to attachpublic void attachAll(java.lang.Iterable<AppState> states)
states
- The states to attachpublic boolean detach(AppState state)
state
- The state to detachpublic boolean hasState(AppState state)
state
- The state to checkattach(com.jme3.app.state.AppState)
public <T extends AppState> T getState(java.lang.Class<T> stateClass)
T
- stateClass
- public <T extends AppState> T getState(java.lang.Class<T> stateClass, boolean failOnMiss)
T
- stateClass
- failOnMiss
- public <T extends AppState> T getState(java.lang.String id, java.lang.Class<T> stateClass)
public boolean hasState(java.lang.String id)
public <T extends AppState> T stateForId(java.lang.String id, java.lang.Class<T> stateClass)
protected void initializePending()
protected void terminatePending()
public void update(float tpf)
tpf
- Time per frame.public void render(RenderManager rm)
rm
- The RenderManagerpublic void postRender()
public void cleanup()