Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

  • new Scene<TActivationData>(): Scene<TActivationData>

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.

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

The ECS world for the scene

Accessors

  • get actors(): readonly Actor[]
  • get entities(): readonly Entity[]
  • get isInitialized(): boolean
  • Gets whether or not the Scene has been initialized

    Returns boolean

  • get timers(): readonly Timer[]

Methods

  • 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.

    internal

    Parameters

    Returns void

  • 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.

    internal

    Parameters

    Returns void

  • _initialize(engine: Engine): void
  • 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

    internal

    Parameters

    Returns void

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

    Internal _postdraw handler for onPostDraw lifecycle event

    internal

    Parameters

    Returns void

  • _postupdate(_engine: Engine, delta: number): void
  • It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Internal _preupdate handler for onPostUpdate lifecycle event

    internal

    Parameters

    Returns void

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

    Internal _predraw handler for onPreDraw lifecycle event

    internal

    Parameters

    Returns void

  • _preupdate(_engine: Engine, delta: number): void
  • It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Internal _preupdate handler for onPreUpdate lifecycle event

    internal

    Parameters

    Returns void

  • clear(deferred?: boolean): 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

  • contains(actor: Actor): boolean
  • Checks whether an actor is contained in this scene or not

    Parameters

    Returns boolean

  • Draws all the actors in the Scene. Called by the Engine.

    Parameters

    • ctx: ExcaliburGraphicsContext

      The current rendering context

    • delta: number

      The number of milliseconds since the last draw

    Returns void

  • emit(eventName: string, eventObject: any): void
  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • isCurrentScene(): boolean
  • isTimerActive(timer: Timer): boolean
  • This is called when the scene is made active and started. It is meant to be overridden, this is where you should setup any DOM UI or event handlers needed for the scene.

    Parameters

    Returns void

  • This is called when the scene is made transitioned away from and stopped. It is meant to be overridden, this is where you should cleanup any DOM UI or event handlers needed for the scene.

    Parameters

    Returns void

  • onInitialize(_engine: Engine): void
  • 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 onPostDraw lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPostDraw is called directly after a scene is drawn.

    Parameters

    Returns void

  • onPostUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPostUpdate is called directly after a scene is updated.

    Parameters

    Returns void

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

    onPreDraw is called directly before a scene is drawn.

    Parameters

    Returns void

  • onPreUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPreUpdate is called directly before a scene is updated.

    Parameters

    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

  • update(engine: Engine, delta: number): 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