Package com.jme3.app.state
Class AbstractAppState
java.lang.Object
com.jme3.app.state.AbstractAppState
- All Implemented Interfaces:
AppState
- Direct Known Subclasses:
AWTComponentAppState
,BulletAppState
,BulletDebugAppState
,ChaseCameraAppState
,DebugKeysAppState
,FlyCamAppState
,MaterialDebugAppState
,ResetStatsState
,RootNodeAppState
,ScreenshotAppState
,StatsAppState
,VideoRecorderAppState
,VRAppState
AbstractAppState
implements some common methods
that make creation of AppStates easier.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
initialized
is set to true when the methodinitialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)
is called. -
Constructor Summary
-
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 enabled) Enable or disable the functionality of theAppState
.protected void
Sets the unique ID of this app state.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
.
-
Field Details
-
initialized
protected boolean initializedinitialized
is set to true when the methodinitialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)
is called. Whencleanup()
is called,initialized
is set back to false.
-
-
Constructor Details
-
AbstractAppState
protected AbstractAppState() -
AbstractAppState
-
-
Method Details
-
initialize
Description copied from interface:AppState
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.- Specified by:
initialize
in interfaceAppState
- Parameters:
stateManager
- The state managerapp
- The application
-
isInitialized
public boolean isInitialized()- Specified by:
isInitialized
in interfaceAppState
- Returns:
- True if
initialize()
was called on the state, false otherwise.
-
setId
Sets the unique ID of this app state. Note: that setting this while an app state is attached to the state manager will have no effect on ID-based lookups.- Parameters:
id
- the desired ID
-
getId
Description copied from interface:AppState
Returns the unique ID for this AppState or null if it has no unique ID. -
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:AppState
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 toAppState.update(float)
,AppState.render(RenderManager)
, orAppState.postRender()
from itsAppStateManager
.- Specified by:
setEnabled
in interfaceAppState
- Parameters:
enabled
- activate the AppState or not.
-
isEnabled
public boolean isEnabled() -
stateAttached
Description copied from interface:AppState
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
AppState.initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)
instead.- Specified by:
stateAttached
in interfaceAppState
- Parameters:
stateManager
- State manager to which the state was attached to.
-
stateDetached
Description copied from interface:AppState
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
AppState.cleanup()
instead.- Specified by:
stateDetached
in interfaceAppState
- Parameters:
stateManager
- The state manager from which the state was detached from.
-
update
public void update(float tpf) Description copied from interface:AppState
Called to update theAppState
. This method will be called every render pass if theAppState
is both attached and enabled. -
render
Description copied from interface:AppState
Render the state. This method will be called every render pass if theAppState
is both attached and enabled. -
postRender
public void postRender()Description copied from interface:AppState
Called after all rendering commands are flushed. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
postRender
in interfaceAppState
-
cleanup
public void cleanup()Description copied from interface:AppState
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).
-