jetlag2d
    Preparing search index...

    Class Scene<P>

    A Scene is a container that represents an interactive, dynamic, visible portion of a game. Every scene has actors inside of it, via its physics world, and also has a timer and a camera.

    There are three primary uses of Scenes:

    • World: This is the scene in which all of the action takes place during gameplay. It is likely to use an advanced physics world, with a more robust collision system.
    • Hud: This is the heads-up display that sits on top of the World scene, and provides a user interface.
    • Overlay: We use short-lived scenes that obscure the world for situations like starting a level, winning/losing a level, and pausing a level.

    Type Parameters

    Index

    A camera, for making sure important actors are on screen

    oneTimeEvents: (() => void)[] = []

    Events that get processed on the next render, then discarded

    physics: P

    The physics system for the scene * *

    repeatEvents: ((dt: number) => void)[] = []

    Events that get processed on every render. Each one is given dt, the number of seconds since the previous render.

    timer: TimerService = ...

    A timer, for creating time-based events

    • get gravity(): { x: number; y: number }

      The gravity in this world

      Returns { x: number; y: number }

      • x: number

        The gravitational force in the x dimension

      • y: number

        The gravitational force in the y dimension (remember up is negative!)

    • set gravity(g: { x: number; y: number }): void

      Set (or reset) the gravity in this world

      Parameters

      • g: { x: number; y: number }
        • x: number

          The gravitational force in the x dimension

        • y: number

          The gravitational force in the y dimension (remember up is negative!)

      Returns void