Camera2d

Extends: Camera

Properties

  • top (float)
  • bottom (float)
  • right (float)
  • left (float)
  • near (float)
  • far (float)
  • name (string)

Constructor

new Camera2d(): Camera2d

Instance Methods

setTarget(targetPos: BGE.Math.Vector): void

Parameters

  • targetPos (BGE.Math.Vector)

Returns

  • void

setBounds(x: float, y: float, width: float, height: float): void

Keeps the view inside a world rectangle (world +y up, so (x, y) is its bottom-left corner), e.g. a level's extent, so the camera never shows past its edges. On an axis where the rectangle is smaller than the view, the view is centred on it instead.

Parameters

  • x (float) — left edge
  • y (float) — bottom edge
  • width (float)
  • height (float)

Returns

  • void

clearBounds(): void

Stops keeping the view inside a rectangle.

Returns

  • void

follow(entity: GameEntity): void

Centres the camera on an entity's position every frame, just before drawing, so the view is never a frame behind the entity's movement. Bounds from setBounds() still apply. Following stops by itself once the entity is destroyed.

Parameters

  • entity (GameEntity) — the entity to follow, or invalid to stop following

Returns

  • void

stopFollowing(): void

Stops following the entity passed to follow().

Returns

  • void

checkMovement(): void

Returns

  • void

rotate(rotation: BGE.Math.Vector): void

Parameters

  • rotation (BGE.Math.Vector)

Returns

  • void

isInView(point: BGE.Math.Vector): boolean

Parameters

  • point (BGE.Math.Vector)

Returns

  • boolean

isAnyInView(points: Array.<BGE.Math.Vector>): boolean

Parameters

  • points (Array.<BGE.Math.Vector>)

Returns

  • boolean

computeWorldToCameraMatrix(): void

Returns

  • void

distanceFromCameraFront(point: BGE.Math.Vector): float

Parameters

  • point (BGE.Math.Vector)

Returns

  • float

worldPointToCanvasPoint( pWorld: BGE.Math.Vector, ): BGE.Math.Vector

Parameters

  • pWorld (BGE.Math.Vector)

Returns

  • BGE.Math.Vector