public interface AppState
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.
initialize() will be called
on the following render pass.
cleanup() will be called
on the following render pass.
AppState then the second attach
is a no-op and will return false.
AppState within one frame then
neither initialize() or cleanup() will be called,
although if either is called both will be.
AppState within one frame
then on the next update pass its cleanup() and initialize()
methods will be called in that order.
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Called by
AppStateManager when transitioning this
AppState from terminating to detached. |
java.lang.String |
getId()
Returns the unique ID for this AppState or null if it has no
unique ID.
|
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. |
boolean |
isEnabled() |
boolean |
isInitialized() |
void |
postRender()
Called after all rendering commands are flushed.
|
void |
render(RenderManager rm)
Render the state.
|
void |
setEnabled(boolean active)
Enable or disable the functionality of the
AppState. |
void |
stateAttached(AppStateManager stateManager)
Called by
AppStateManager.attach(com.jme3.app.state.AppState)
when transitioning this
AppState from detached to initializing. |
void |
stateDetached(AppStateManager stateManager)
Called by
AppStateManager.detach(com.jme3.app.state.AppState)
when transitioning this
AppState from running to terminating. |
void |
update(float tpf)
Called to update the
AppState. |
void initialize(AppStateManager stateManager, Application app)
AppStateManager when transitioning this AppState
from initializing to running.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.
stateManager - The state managerapp - The applicationboolean isInitialized()
initialize() was called on the state,
false otherwise.java.lang.String getId()
void setEnabled(boolean active)
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.active - activate the AppState or not.boolean isEnabled()
AppState is enabled, false otherwise.setEnabled(boolean)void stateAttached(AppStateManager stateManager)
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.
stateManager - State manager to which the state was attached to.void stateDetached(AppStateManager stateManager)
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.
stateManager - The state manager from which the state was detached from.void update(float tpf)
AppState. This method will be called
every render pass if the AppState is both attached and enabled.tpf - Time since the last call to update(), in seconds.void render(RenderManager rm)
AppState is both attached and enabled.rm - RenderManagervoid postRender()
AppState is both attached and enabled.void cleanup()
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).