Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

Creates a DuckEngine Camera

description

The Camera Class. Creates and uses a viewport that acts like a camera

since

1.0.0-beta

Hierarchy

  • Camera

Index

Constructors

constructor

Properties

Protected aspectRatio

aspectRatio: undefined | number

Protected bounds

bounds: undefined | { h: number; position: { x: number; y: number }; w: number }

distance

distance: number
memberof

Camera

description

The Camera's current zoom

since

2.1.0

fieldOfView

fieldOfView: number
memberof

Camera

description

The Camera's current FOV

since

2.1.0

following

memberof

Camera

description

A gameobject that the Camera is currently following

since

game

game: Game
memberof

Camera

description

Game instance

since

1.0.0-beta

Readonly isMain

isMain: boolean
memberof

Camera

description

Determines if the camera is a main camera in the attached scene. Must be added by Scene.mainCamera

since

1.0.0-beta

Protected lerpX

lerpX: number = 1

Protected lerpY

lerpY: number = 1

Protected lookAt

lookAt: number[]

scene

scene: Scene
memberof

Camera

description

Scene instance

since

2.0.0

viewport

viewport: { bottom: number; h: number; left: number; right: number; scale: number[]; top: number; w: number }
memberof

Camera

description

Camera's viewport, has info about the viewport

since

1.0.0-beta

Type declaration

  • bottom: number
  • h: number
  • left: number
  • right: number
  • scale: number[]
  • top: number
  • w: number

Accessors

defaultFOV

  • get defaultFOV(): number

defaultZoom

  • get defaultZoom(): number
  • memberof

    Camera

    description

    Returns the default zoom, also uses DPR scaling if enabled

    since

    1.0.0

    Returns number

Methods

Protected applyScale

  • applyScale(): void

Protected applyTranslation

  • applyTranslation(): void

autoCull

  • memberof

    Camera

    description

    A form of Frustum Culling that gets all objects visible to the player by the viewport's width and height and culls those objects and does not render objects outside/not-visible to the player/camera

    since

    2.0.0

    Parameters

    Returns void

begin

  • begin(): void
  • memberof

    Camera

    description

    Begins camera path

    DO NOT CALL MANUALLY, CALLED IN GAME -> SCENE LOOP AUTOMATICALLY

    since

    1.0.0-beta

    Returns void

cull

  • memberof

    Camera

    description

    Culls/Renders objects that are passed and does not render other object that are not passed

    since

    2.0.0

    Parameters

    Returns void

end

  • end(): void
  • memberof

    Camera

    description

    Ends camera path

    DO NOT CALL MANUALLY, CALLED IN GAME -> SCENE LOOP AUTOMATICALLY

    since

    1.0.0-beta

    Returns void

moveTo

  • moveTo(x: number, y: number): void
  • memberof

    Camera

    description

    Moves the camera to a position

    since

    1.0.0-beta

    Parameters

    • x: number

      X position

    • y: number

      Y position

    Returns void

resetFOV

  • resetFOV(): void
  • memberof

    Camera

    description

    Resets the FOV to the default value

    since

    1.0.0-beta

    Returns void

resetZoom

  • resetZoom(): void
  • memberof

    Camera

    description

    Resets the Zoom to the default value

    since

    1.0.0-beta

    Returns void

screenToWorld

setBounds

  • setBounds(bounds: { h: number; position: { x: number; y: number }; w: number }): void
  • memberof

    Camera

    description

    Bounds of the Camera, an area the camera can be in

    since

    1.0.0-beta

    Parameters

    • bounds: { h: number; position: { x: number; y: number }; w: number }
      • h: number
      • position: { x: number; y: number }
        • x: number
        • y: number
      • w: number

    Returns void

setFOV

  • setFOV(f: number): void
  • memberof

    Camera

    description

    Sets the FOV

    since

    1.0.0-beta

    Parameters

    • f: number

      FOV value

    Returns void

setFOVSmooth

  • setFOVSmooth(intervalMS: number, smoothValue: number, f: number): void
  • memberof

    Camera

    description

    Sets the FOV smoothly

    since

    1.0.0-beta

    Parameters

    • intervalMS: number

      How often FOV is modified by smoothValue

    • smoothValue: number

      The number that is added to FOV on an interval

    • f: number

      Target FOV value

    Returns void

setZoom

  • setZoom(z: number): void
  • memberof

    Camera

    description

    Sets the zoom

    since

    1.0.0-beta

    Parameters

    • z: number

      Zoom value

    Returns void

setZoomSmooth

  • setZoomSmooth(intervalMS: number, smoothValue: number, z: number): void
  • memberof

    Camera

    description

    Sets the zoom smoothly

    since

    1.0.0-beta

    Parameters

    • intervalMS: number

      How often zoom is modified by smoothValue

    • smoothValue: number

      The number that is added to zoom on an interval

    • z: number

      Target Zoom value

    Returns void

shake

  • shake(intervalMS: number, timeMS: number, v: number): void
  • memberof

    Camera

    description

    Shakes the camera

    since

    1.0.0

    Parameters

    • intervalMS: number

      How often (in milliseconds) the passed value is added/subtracted from the Camera viewport position

    • timeMS: number

      For how long in milliseconds the shake lasts

    • v: number

      Value to be added/subtracted from the Camera viewport position

    Returns void

startFollow

stopFollow

  • stopFollow(): void

Protected updateViewport

  • updateViewport(): void

worldToScreen

Generated using TypeDoc