diff --git a/engine/src/core/com/jme3/app/state/AppState.java b/engine/src/core/com/jme3/app/state/AppState.java
index fb31dddac..34af8906a 100644
--- a/engine/src/core/com/jme3/app/state/AppState.java
+++ b/engine/src/core/com/jme3/app/state/AppState.java
@@ -35,24 +35,46 @@ import com.jme3.app.Application;
import com.jme3.renderer.RenderManager;
/**
- * AppState represents a continously executing code inside the main loop.
+ * AppState represents continously executing code inside the main loop.
+ *
* An AppState
can track when it is attached to the
- * {@link AppStateManager} or when it is detached. AppState
s
- * are initialized in the render thread, upon a call to {@link AppState#initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application) }
+ * {@link AppStateManager} or when it is detached.
+ *
+ * AppState
s are initialized in the render thread, upon a call to
+ * {@link AppState#initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application) }
* and are de-initialized upon a call to {@link AppState#cleanup()}.
* Implementations should return the correct value with a call to
* {@link AppState#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.
+ * AppState
. This method is called
+ * in the next render pass after the AppState
is attached.
*
* @param stateManager The state manager
- * @param app
+ * @param app The application
*/
public void initialize(AppStateManager stateManager, Application app);
@@ -77,22 +99,28 @@ public interface AppState {
* @see AppState#setEnabled(boolean)
*/
public boolean isEnabled();
+
/**
- * Called when the state was attached.
+ * Called when the state was attached. Most implementations should do little
+ * or nothing in this method. In particular any scene graph changes need to
+ * be made in initialize()
.
*
* @param stateManager State manager to which the state was attached to.
*/
public void stateAttached(AppStateManager stateManager);
/**
- * Called when the state was detached.
+ * Called when the state was detached. Most implementations should do little
+ * or nothing in this method. In particular any scene graph changes need to
+ * be made in cleanup()
.
*
* @param stateManager The state manager from which the state was detached from.
*/
public void stateDetached(AppStateManager stateManager);
/**
- * Called to update the state.
+ * Called to update the AppState
. This method will be called
+ * every render pass if the AppState
is both attached and enabled.
*
* @param tpf Time per frame.
*/
@@ -111,7 +139,12 @@ public interface AppState {
public void postRender();
/**
- * Cleanup the game state.
+ * Called to clean up the AppState
after it has been removed. 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).
+ *
*/
public void cleanup();