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
The [[TileMap]]s in the scene, if any
Returns readonly TileMap[]
publictimers
Returns readonly Timer[]
publictriggers
The triggers in the current scene
Returns readonly Trigger[]
Methods
publicadd
Adds a [[Timer]] to the current [[Scene]].
Parameters
timer: Timer
The timer to add to the current [[Scene]].
Returns void
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
delta: 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
Tests whether a [[Timer]] is active in the scene
Parameters
timer: Timer
Returns boolean
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
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
engine: Engine<any>
Returns void
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
delta: 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>
delta: 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
delta: 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>
delta: 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
publicremove
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
publicremoveTimer
publictransfer
Removes a [[Timer]] from it's current scene and adds it to this scene.
Useful if you want to have an object be present in only 1 scene at a time.
Parameters
timer: Timer
The Timer to transfer to the current scene
Returns void
publicupdate
Updates all the actors and timers in the scene. Called by the [[Engine]].
Parameters
engine: Engine<any>
Reference to the current Engine
delta: number
The number of milliseconds since the last update
Returns void
[[Actor|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.