Scene <TActivationData>
Implements
- CanInitialize
- CanActivate<TActivationData>
- CanDeactivate
- CanUpdate
- CanDraw
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Type parameters
- TActivationData = unknown
Returns Scene<TActivationData>
Properties
publicoptionalbackgroundColor
Scene specific background color
publiccamera
Gets or sets the current camera for the scene
publicengine
Access to the Excalibur engine
publicevents
publicinput
Access scene specific input, handlers on this only fire when this scene is active.
publicphysics
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.
publicworld
The ECS world for the scene
Accessors
publicactors
The actors in the current scene
Returns readonly Actor[]
publicentities
The entities in the current scene
Returns readonly Entity<any>[]
publicisInitialized
Gets whether or not the Scene has been initialized
Returns boolean
publictileMaps
publictimers
Returns readonly Timer[]
publictriggers
The triggers in the current scene
Returns readonly Trigger[]
Methods
publicadd
publicaddTimer
publiccancelTimer
publicclear
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
publiccontains
Checks whether an actor is contained in this scene or not
Parameters
actor: Actor
Returns boolean
publicdebugDraw
Draws all the actors' debug information in the Scene. Called by the Engine.
Parameters
ctx: ExcaliburGraphicsContext
The current rendering context
Returns void
publicdraw
Draws all the actors in the Scene. Called by the Engine.
Parameters
ctx: ExcaliburGraphicsContext
The current rendering context
elapsedMs: number
The number of milliseconds since the last draw
Returns void
publicemit
Type parameters
- TEventName: EventKey<SceneEvents>
Parameters
eventName: TEventName
event: SceneEvents[TEventName]
Returns void
publicisCurrentScene
Returns boolean
publicisTimerActive
publicoff
Type parameters
- TEventName: EventKey<SceneEvents>
Parameters
eventName: TEventName
handler: Handler<SceneEvents[TEventName]>
Returns void
publicon
Event signatures
Type parameters
- TEventName: EventKey<SceneEvents>
Parameters
eventName: TEventName
handler: Handler<SceneEvents[TEventName]>
Returns Subscription
publiconActivate
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
context: SceneActivationContext<TActivationData>
Returns void
publiconDeactivate
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
context: SceneActivationContext<undefined>
Returns void
publiconInitialize
publiconPostDraw
Safe to override onPostDraw lifecycle event handler. Synonymous with
.on('preupdate', (evt) =>{...})
onPostDraw
is called directly after a scene is drawn.Parameters
ctx: ExcaliburGraphicsContext
elapsedMs: number
Returns void
publiconPostUpdate
Safe to override onPostUpdate lifecycle event handler. Synonymous with
.on('preupdate', (evt) =>{...})
onPostUpdate
is called directly after a scene is updated.Parameters
engine: Engine<any>
elapsedMs: number
Returns void
publiconPreDraw
Safe to override onPreDraw lifecycle event handler. Synonymous with
.on('preupdate', (evt) =>{...})
onPreDraw
is called directly before a scene is drawn.Parameters
ctx: ExcaliburGraphicsContext
elapsedMs: number
Returns void
publiconPreLoad
Event hook to provide Scenes a way of loading scene specific resources.
This is called before the Scene.onInitialize during scene transition. It will only ever fire once for a scene.
Parameters
loader: DefaultLoader
Returns void
publiconPreUpdate
Safe to override onPreUpdate lifecycle event handler. Synonymous with
.on('preupdate', (evt) =>{...})
onPreUpdate
is called directly before a scene is updated.Parameters
engine: Engine<any>
elapsedMs: number
Returns void
publiconTransition
Event hook fired directly before transition, either "in" or "out" of the scene
This overrides the Engine scene definition. However transitions specified in goToScene take highest precedence
// Overrides all Engine.goToScene('scene', { destinationIn: ..., sourceOut: ... });
This can be used to configure custom transitions for a scene dynamically
Parameters
direction: in | out
Returns Transition
publiconce
Type parameters
- TEventName: EventKey<SceneEvents>
Parameters
eventName: TEventName
handler: Handler<SceneEvents[TEventName]>
Returns Subscription
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.