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.

Constructors

  • Construct a new scene

    Parameters

    Returns Scene

Properties

A camera, for making sure important actors are on screen

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

Events that get processed on the next render, then discarded

Type declaration

    • (): void
    • Returns void

The physics system for the scene

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

Events that get processed on every render

Type declaration

    • (): void
    • Returns void

timer: TimerService = ...

A timer, for creating time-based events

Methods

  • Run any pending events that should happen during a render

    Returns void

  • Set (or reset) the gravity in this world

    Parameters

    • x: number

      The gravitational force in the x dimension

    • y: number

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

    Returns void