Class SceneManager

java.lang.Object
nl.colorize.multimedialib.scene.SceneManager

public class SceneManager extends Object
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 Details

    • SceneManager

      public SceneManager(nl.colorize.util.Stopwatch timer)
    • SceneManager

      public SceneManager()
  • Method Details

    • requestFrameUpdate

      public int requestFrameUpdate(SceneContext context)
      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 deltaTime value, 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 FrameStats instance 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

      protected void performFrameUpdate(SceneContext context, float deltaTime)
      Performs an application frame update. The renderer will first call requestFrameUpdate(SceneContext), which then calls this method depending on how much time has elapsed since the last frame.
    • changeScene

      public void changeScene(Scene requestedScene)
      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

      public void attach(SceneContext context, Scene subScene)
      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

      public void attachGlobal(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. Multiple global scenes can be attached.
    • isActiveScene

      public boolean isActiveScene(Scene scene)
      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

      public FrameStats getFrameStats()