Package nl.colorize.multimedialib.scene
Class SceneManager
java.lang.Object
nl.colorize.multimedialib.scene.SceneManager
Controls the scene life cycle, including the life cycle of its attached
sub-scenes. The scene manager is accessible to the currently active scene
via the
SceneContext.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(SceneContext context, Scene subScene) Attaches a sub-scene to the currently active scene.voidattachGlobal(SceneContext context, Scene globalSubScene) Attaches a scene that is *not* tied to the currently active scene, and will remain active for the rest of the application.voidchangeScene(Scene requestedScene) Requests to change the active scene after the current frame update has been completed.booleanisActiveScene(Scene scene) Returns true if the specified scene is currently active.protected voidperformFrameUpdate(SceneContext context, float deltaTime) Performs an application frame update.intrequestFrameUpdate(SceneContext context) Synchronizes between "native" frames and application frame updates.
-
Constructor Details
-
SceneManager
public SceneManager(nl.colorize.util.Stopwatch timer) -
SceneManager
public SceneManager()
-
-
Method Details
-
requestFrameUpdate
Synchronizes between "native" frames and application frame updates. Should be called by the renderer during every "native" frame. Depending on the elapsed time and target framerate, this method will then perform application frame updates.Although this class provides the renderer with the delta time since the last frame update, this may not always reflect the actual elapsed time. it is not realistic to expect applications to be able to function correctly for every possible
deltaTimevalue, so this method will attempt to produce frame updates that try to find a balance between the targeted framerate and the actual elapsed time.Note that rendering the frame is not managed by this method. The renderer should make sure that every "native" frame is rendered, even if that frame did not lead to an application frame update.
Calling this method will also register the corresponding performance statistics with the
FrameStatsinstance provided in the constructor.- Returns:
- The number of application frame updates that were performed during the frame synchronization process. A value of zero indicates no frame updates were performed, meaning that it is not necessary for the renderer to render the frame.
-
performFrameUpdate
Performs an application frame update. The renderer will first callrequestFrameUpdate(SceneContext), which then calls this method depending on how much time has elapsed since the last frame. -
changeScene
Requests to change the active scene after the current frame update has been completed. If another scene had already been requested, calling this method again will overrule that request. -
attach
Attaches a sub-scene to the currently active scene. The sub-scene will remain active until it is detached or the parent scene ends. -
attachGlobal
Attaches a scene that is *not* tied to the currently active scene, and will remain active for the rest of the application. Multiple global scenes can be attached. -
isActiveScene
Returns true if the specified scene is currently active. Note this will also return true if the specified scene has been attached as a sub-scene. -
getFrameStats
-