Class Scene<TActivationData>

Actors are composed together into groupings called Scenes in Excalibur. The metaphor models the same idea behind real world actors in a scene. Only actors in scenes will be updated and drawn.

Typical usages of a scene include: levels, menus, loading screens, etc.

Type Parameters

  • TActivationData = unknown

Hierarchy

Implements

Constructors

Properties

camera: Camera = ...

Gets or sets the current camera for the scene

engine: Engine

Access to the Excalibur engine

eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

physics: PhysicsWorld = ...

The Excalibur physics world for the scene. Used to interact with colliders included in the scene.

Can be used to perform scene ray casts, track colliders, broadphase, and narrowphase.

world: World<Scene<TActivationData>> = ...

The ECS world for the scene

Accessors

  • get actors(): readonly Actor[]
  • The actors in the current scene

    Returns readonly Actor[]

  • get entities(): readonly Entity[]
  • The entities in the current scene

    Returns readonly Entity[]

  • get isInitialized(): boolean
  • Gets whether or not the Scene has been initialized

    Returns boolean

Methods

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Activates the scene with the base behavior, then calls the overridable onActivate implementation.

    Parameters

    Returns void

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Deactivates the scene with the base behavior, then calls the overridable onDeactivate implementation.

    Parameters

    Returns void

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Initializes the scene before the first update, meant to be called by engine not by users of Excalibur

    Parameters

    Returns void

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Internal _preupdate handler for onPostUpdate lifecycle event

    Parameters

    • _engine: Engine
    • delta: number

    Returns void

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Internal _preupdate handler for onPreUpdate lifecycle event

    Parameters

    • _engine: Engine
    • delta: number

    Returns void

  • Removes all entities and timers from the scene, optionally indicate whether deferred should or shouldn't be used.

    By default entities use deferred removal

    Parameters

    • deferred: boolean = true

    Returns void

  • Checks whether an actor is contained in this scene or not

    Parameters

    Returns boolean

  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • Returns boolean

  • Tests whether a Timer is active in the scene

    Parameters

    Returns boolean

  • This is called before the first update of the Scene. Initializes scene members like the camera. This method is meant to be overridden. This is where initialization of child actors should take place.

    Parameters

    Returns void

  • Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPostUpdate is called directly after a scene is updated.

    Parameters

    • _engine: Engine
    • _delta: number

    Returns void

  • Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPreUpdate is called directly before a scene is updated.

    Parameters

    • _engine: Engine
    • _delta: number

    Returns void

  • Removes a Timer from the current scene, it will no longer be updated.

    Parameters

    • timer: Timer

      The timer to remove to the current scene.

    Returns void

  • Removes a TileMap from the scene, it will no longer be drawn or updated.

    Parameters

    Returns void

  • Removes an actor from the scene, it will no longer be drawn or updated.

    Parameters

    • actor: Actor

      The actor to remove from the current scene.

    Returns void

  • Parameters

    Returns void

  • Removes a ScreenElement to the scene, it will no longer be drawn or updated

    Parameters

    • screenElement: ScreenElement

      The ScreenElement to remove from the current scene

    Returns void

  • Updates all the actors and timers in the scene. Called by the Engine.

    Parameters

    • engine: Engine

      Reference to the current Engine

    • delta: number

      The number of milliseconds since the last update

    Returns void