Package com.jme3.app.state
Interface AppState
- All Known Implementing Classes:
AbstractAppState,ArmatureDebugAppState,AudioListenerState,AWTComponentAppState,BaseAppState,BasicProfilerState,BulletAppState,BulletDebugAppState,ChaseCameraAppState,Cinematic,CompositeAppState,ConstantVerifierState,DebugKeysAppState,DetailedProfilerState,EnvironmentCamera,FlyCamAppState,LightsDebugState,MaterialDebugAppState,ResetStatsState,RootNodeAppState,ScreenshotAppState,StatsAppState,VideoRecorderAppState,VRAppState
public interface AppState
AppState represents continuously executing code inside the main loop.
An
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.
- If a detached AppState is attached then
initialize()will be called on the following render pass. - If an attached AppState is detached then
cleanup()will be called on the following render pass. - If you attach an already-attached
AppStatethen the second attach is a no-op and will return false. - If you both attach and detach an
AppStatewithin one frame then neitherinitialize()orcleanup()will be called, although if either is called both will be. - If you both detach and then re-attach an
AppStatewithin one frame then on the next update pass itscleanup()andinitialize()methods will be called in that order.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Called byAppStateManagerwhen transitioning thisAppStatefrom terminating to detached.getId()Returns the unique ID for this AppState or null if it has no unique ID.voidinitialize(AppStateManager stateManager, Application app) Called byAppStateManagerwhen transitioning thisAppStatefrom initializing to running.
This will happen on the next iteration through the update loop afterAppStateManager.attach(com.jme3.app.state.AppState)was called.booleanbooleanvoidCalled after all rendering commands are flushed.voidrender(RenderManager rm) Render the state.voidsetEnabled(boolean active) Enable or disable the functionality of theAppState.voidstateAttached(AppStateManager stateManager) Called byAppStateManager.attach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom detached to initializing.voidstateDetached(AppStateManager stateManager) Called byAppStateManager.detach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom running to terminating.voidupdate(float tpf) Called to update theAppState.
-
Method Details
-
initialize
Called byAppStateManagerwhen transitioning thisAppStatefrom initializing to running.
This will happen on the next iteration through the update loop afterAppStateManager.attach(com.jme3.app.state.AppState)was called.AppStateManagerwill call this only from the update loop inside the rendering thread. This means is it safe to modify the scene graph from this method.- Parameters:
stateManager- The state managerapp- The application
-
isInitialized
boolean isInitialized()- Returns:
- True if
initialize()was called on the state, false otherwise.
-
getId
String getId()Returns the unique ID for this AppState or null if it has no unique ID.- Returns:
- the ID, or null if none
-
setEnabled
void setEnabled(boolean active) Enable or disable the functionality of theAppState. The effect of this call depends on implementation. AnAppStatestarts as being enabled by default. A disabledAppStates does not get calls toupdate(float),render(RenderManager), orpostRender()from itsAppStateManager.- Parameters:
active- activate the AppState or not.
-
isEnabled
boolean isEnabled()- Returns:
- True if the
AppStateis enabled, false otherwise. - See Also:
-
stateAttached
Called byAppStateManager.attach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom 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.- Parameters:
stateManager- State manager to which the state was attached to.
-
stateDetached
Called byAppStateManager.detach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom 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.- Parameters:
stateManager- The state manager from which the state was detached from.
-
update
void update(float tpf) Called to update theAppState. This method will be called every render pass if theAppStateis both attached and enabled.- Parameters:
tpf- Time since the last call to update(), in seconds.
-
render
Render the state. This method will be called every render pass if theAppStateis both attached and enabled.- Parameters:
rm- RenderManager
-
postRender
void postRender()Called after all rendering commands are flushed. This method will be called every render pass if theAppStateis both attached and enabled. -
cleanup
void cleanup()Called byAppStateManagerwhen transitioning thisAppStatefrom terminating to detached. This method is called the following render pass after theAppStatehas been detached and is always called once and only once for each timeinitialize()is called. Either when theAppStateis detached or when the application terminates (if it terminates normally).
-