public abstract class AbstractAppState extends java.lang.Object implements AppState
AbstractAppState
implements some common methods
that make creation of AppStates easier.BaseAppState
Modifier and Type | Field and Description |
---|---|
protected boolean |
initialized
initialized is set to true when the method
initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)
is called. |
Modifier | Constructor and Description |
---|---|
protected |
AbstractAppState() |
protected |
AbstractAppState(java.lang.String id) |
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 enabled)
Enable or disable the functionality of the
AppState . |
protected void |
setId(java.lang.String id)
Sets the unique ID of this app state.
|
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 . |
protected boolean initialized
initialized
is set to true when the method
initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)
is called. When cleanup()
is called, initialized
is set back to false.protected AbstractAppState()
protected AbstractAppState(java.lang.String id)
public void initialize(AppStateManager stateManager, Application app)
AppState
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.
initialize
in interface AppState
stateManager
- The state managerapp
- The applicationpublic boolean isInitialized()
isInitialized
in interface AppState
initialize()
was called on the state,
false otherwise.protected void setId(java.lang.String id)
id
- the desired IDpublic java.lang.String getId()
AppState
public void setEnabled(boolean enabled)
AppState
AppState
.
The effect of this call depends on implementation. An
AppState
starts as being enabled by default.
A disabled AppState
s does not get calls to
AppState.update(float)
, AppState.render(RenderManager)
, or
AppState.postRender()
from its AppStateManager
.setEnabled
in interface AppState
enabled
- activate the AppState or not.public boolean isEnabled()
isEnabled
in interface AppState
AppState
is enabled, false otherwise.AppState.setEnabled(boolean)
public void stateAttached(AppStateManager stateManager)
AppState
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.
stateAttached
in interface AppState
stateManager
- State manager to which the state was attached to.public void stateDetached(AppStateManager stateManager)
AppState
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.
stateDetached
in interface AppState
stateManager
- The state manager from which the state was detached from.public void update(float tpf)
AppState
AppState
. This method will be called
every render pass if the AppState
is both attached and enabled.public void render(RenderManager rm)
AppState
AppState
is both attached and enabled.public void postRender()
AppState
AppState
is both attached and enabled.postRender
in interface AppState
public void cleanup()
AppState
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).