Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LockedCamera

An extension of BaseCamera that is locked to an Actor or [[LockedCamera.focus|focal point]]; the actor will appear in the center of the screen.

Common usages: RPGs, adventure games, top-down games.

Hierarchy

Index

Properties

Protected _follow

_follow: Actor

Protected _isShaking

_isShaking: boolean = false

Protected _isZooming

_isZooming: boolean = false

ax

ax: number = 0

ay

ay: number = 0

az

az: number = 0

dx

dx: number = 0

dy

dy: number = 0

dz

dz: number = 0

rotation

rotation: number = 0

rx

rx: number = 0

z

z: number = 1

Accessors

x

  • 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

y

  • 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

Methods

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D): void
  • Parameters

    • ctx: CanvasRenderingContext2D

    Returns void

draw

  • draw(ctx: CanvasRenderingContext2D, delta: number): void
  • Applies the relevant transformations to the game canvas to "move" or apply effects to the Camera

    Parameters

    • ctx: CanvasRenderingContext2D

      Canvas context to apply transformations

    • delta: number

      The number of milliseconds since the last update

    Returns void

getFocus

getZoom

  • getZoom(): number
  • Gets the current zoom scale

    Returns number

move

  • 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

    • Default value easingFn: EasingFunction = EasingFunctions.EaseInOutCubic

    Returns IPromise<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.

setActorToFollow

  • setActorToFollow(actor: Actor): void

shake

  • 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

  • update(engine: Engine, delta: number): void
  • Parameters

    • engine: Engine
    • delta: number

    Returns void

zoom

  • zoom(scale: number, duration?: number): void
  • 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

    • Default value duration: number = 0

      The duration of the zoom in milliseconds

    Returns void