Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

Implements

Index

Constructors

Properties

_follow: Actor
_isShaking: boolean = false
_isZooming: boolean = false
acc: Vector = Vector.Zero

Get or set the camera's acceleration

az: number = 0

Get or set zoom acceleration

dz: number = 0

Get or set rate of change in zoom, defaults to 0

eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

inverse: AffineMatrix = ...
rotation: number = 0

Current rotation of the camera

strategy: StrategyContainer = ...
transform: AffineMatrix = ...
vel: Vector = Vector.Zero

Get or set the camera's velocity

Accessors

  • get angularVelocity(): number
  • set angularVelocity(value: number): void
  • Get or set the camera's angular velocity

    Returns number

  • Get or set the camera's angular velocity

    Parameters

    • value: number

    Returns void

  • get ax(): number
  • set ax(value: number): void
  • Get or set the camera's x acceleration

    Returns number

  • Get or set the camera's x acceleration

    Parameters

    • value: number

    Returns void

  • get ay(): number
  • set ay(value: number): void
  • Get or set the camera's y acceleration

    Returns number

  • Get or set the camera's y acceleration

    Parameters

    • value: number

    Returns void

  • get dx(): number
  • set dx(value: number): void
  • Get or set the camera's x velocity

    Returns number

  • Get or set the camera's x velocity

    Parameters

    • value: number

    Returns void

  • get dy(): number
  • set dy(value: number): void
  • Get or set the camera's y velocity

    Returns number

  • Get or set the camera's y velocity

    Parameters

    • value: number

    Returns void

  • get isInitialized(): boolean
  • get x(): number
  • set x(value: number): void
  • 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

  • get y(): number
  • set y(value: number): void
  • 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

  • get zoom(): number
  • set zoom(val: number): void

Methods

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

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

  • clearAllStrategies(): void
  • Clears all camera strategies from the camera

    Returns void

  • Applies the relevant transformations to the game canvas to "move" or apply effects to the Camera

    Parameters

    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

  • Returns the focal point of the camera, a new point giving the x and y position of the camera

    Returns Vector

  • 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

    • easingFn: Util.EasingFunction = EasingFunctions.EaseInOutCubic

    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.

  • onInitialize(_engine: Engine): 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

  • 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

  • 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

  • runStrategies(engine: Engine, delta: number): void
  • shake(magnitudeX: number, magnitudeY: number, duration: number): void
  • 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

  • update(_engine: Engine, delta: number): void
  • updateTransform(): void
  • updateViewport(): void
  • zoomOverTime(scale: number, duration?: number, easingFn?: Util.EasingFunction): Promise<boolean>
  • 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: Util.EasingFunction = EasingFunctions.EaseInOutCubic

    Returns Promise<boolean>