Camera
Implements
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Returns Camera
Properties
publicacc
Get or set the camera's acceleration
publicaz
Get or set zoom acceleration
publicdrawPos
Interpolated camera position if more draws are running than updates
Enabled when Engine.fixedUpdateFps
is enabled, in all other cases this will be the same as pos
publicdz
Get or set rate of change in zoom, defaults to 0
publicevents
publicinverse
publicrotation
Current rotation of the camera
publicstrategy
publictransform
publicvel
Get or set the camera's velocity
Accessors
publicangularVelocity
Get or set the camera's angular velocity
Returns number
Parameters
value: number
Returns void
publicax
Get or set the camera's x acceleration
Returns number
Parameters
value: number
Returns void
publicay
Get or set the camera's y acceleration
Returns number
Parameters
value: number
Returns void
publicdx
Get or set the camera's x velocity
Returns number
Parameters
value: number
Returns void
publicdy
Get or set the camera's y velocity
Returns number
Parameters
value: number
Returns void
publicisInitialized
Returns boolean
publicpos
publicviewport
Gets the bounding box of the viewport of this camera in world coordinates
Returns BoundingBox
publicx
Get the camera's x position
Returns number
Set the camera's x position (cannot be set when following an [[Actor]] or when moving)
Parameters
value: number
Returns void
publicy
Get the camera's y position
Returns number
Set the camera's y position (cannot be set when following an [[Actor]] or when moving)
Parameters
value: number
Returns void
publiczoom
Returns number
Parameters
val: number
Returns void
Methods
public_initialize
Parameters
engine: Engine<any>
Returns void
publicaddStrategy
Adds a new camera strategy to this camera
Type parameters
- T
Parameters
cameraStrategy: CameraStrategy<T>
Instance of an [[CameraStrategy]]
Returns void
publicclearAllStrategies
Clears all camera strategies from the camera
Returns void
publicdraw
Applies the relevant transformations to the game canvas to "move" or apply effects to the Camera
Parameters
ctx: ExcaliburGraphicsContext
Canvas context to apply transformations
Returns void
publicemit
Type parameters
- TEventName: EventKey<CameraEvents>
Parameters
eventName: TEventName
event: CameraEvents[TEventName]
Returns void
publicgetFocus
Returns the focal point of the camera, a new point giving the x and y position of the camera
Returns Vector
publicmove
This moves the camera focal point to the specified position using specified easing function. Cannot move when following an Actor.
Parameters
pos: Vector
The target position to move to
duration: number
The duration in milliseconds the move should last
optionaleasingFn: EasingFunction = EasingFunctions.EaseInOutCubic
An optional easing function ([[ex.EasingFunctions.EaseInOutCubic]] by default)
Returns Promise<Vector>
A [[Promise]] that resolves when movement is finished, including if it's interrupted. The [[Promise]] value is the [[Vector]] of the target position. It will be rejected if a move cannot be made.
publicoff
Type parameters
- TEventName: EventKey<CameraEvents>
Parameters
eventName: TEventName
handler: Handler<CameraEvents[TEventName]>
Returns void
publicon
Event signature
Type parameters
- TEventName: EventKey<CameraEvents>
Parameters
eventName: TEventName
handler: Handler<CameraEvents[TEventName]>
Returns Subscription
publiconInitialize
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>
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
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
publiconce
Type parameters
- TEventName: EventKey<CameraEvents>
Parameters
eventName: TEventName
handler: Handler<CameraEvents[TEventName]>
Returns Subscription
publicremoveStrategy
Removes a camera strategy by reference
Type parameters
- T
Parameters
cameraStrategy: CameraStrategy<T>
Instance of an [[CameraStrategy]]
Returns void
publicrunStrategies
Parameters
engine: Engine<any>
delta: number
Returns void
publicshake
Sets the camera to shake at the specified magnitudes for the specified duration
Parameters
magnitudeX: number
The x magnitude of the shake
magnitudeY: number
The y magnitude of the shake
duration: number
The duration of the shake in milliseconds
Returns void
publicupdate
Parameters
engine: Engine<any>
delta: number
Returns void
publicupdateTransform
Parameters
pos: Vector
Returns void
publicupdateViewport
Returns void
publiczoomOverTime
Zooms the camera in or out by the specified scale over the specified duration. If no duration is specified, it take effect immediately.
Parameters
scale: number
The scale of the zoom
duration: number = 0
The duration of the zoom in milliseconds
easingFn: EasingFunction = EasingFunctions.EaseInOutCubic
Returns Promise<boolean>
Cameras
[[Camera]] is the base class for all Excalibur cameras. Cameras are used to move around your game and set focus. They are used to determine what is "off screen" and can be used to scale the game.