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.
AppState
s 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
AppState
then the second attach is a no-op and will return false. - If you both attach and detach an
AppState
within 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
AppState
within one frame then on the next update pass itscleanup()
andinitialize()
methods will be called in that order.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Called byAppStateManager
when transitioning thisAppState
from terminating to detached.getId()
Returns the unique ID for this AppState or null if it has no unique ID.void
initialize
(AppStateManager stateManager, Application app) Called byAppStateManager
when transitioning thisAppState
from initializing to running.
This will happen on the next iteration through the update loop afterAppStateManager.attach(com.jme3.app.state.AppState)
was called.boolean
boolean
void
Called after all rendering commands are flushed.void
render
(RenderManager rm) Render the state.void
setEnabled
(boolean active) Enable or disable the functionality of theAppState
.void
stateAttached
(AppStateManager stateManager) Called byAppStateManager.attach(com.jme3.app.state.AppState)
when transitioning thisAppState
from detached to initializing.void
stateDetached
(AppStateManager stateManager) Called byAppStateManager.detach(com.jme3.app.state.AppState)
when transitioning thisAppState
from running to terminating.void
update
(float tpf) Called to update theAppState
.
-
Method Details
-
initialize
Called byAppStateManager
when transitioning thisAppState
from initializing to running.
This will happen on the next iteration through the update loop afterAppStateManager.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.- 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. AnAppState
starts as being enabled by default. A disabledAppState
s 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
AppState
is enabled, false otherwise. - See Also:
-
stateAttached
Called byAppStateManager.attach(com.jme3.app.state.AppState)
when transitioning thisAppState
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.- Parameters:
stateManager
- State manager to which the state was attached to.
-
stateDetached
Called byAppStateManager.detach(com.jme3.app.state.AppState)
when transitioning thisAppState
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.- 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 theAppState
is 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 theAppState
is 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 theAppState
is both attached and enabled. -
cleanup
void cleanup()Called byAppStateManager
when transitioning thisAppState
from terminating to detached. This method is called the following render pass after theAppState
has been detached and is always called once and only once for each timeinitialize()
is called. Either when theAppState
is detached or when the application terminates (if it terminates normally).
-