Foundation.Camera

A Camera object is simply a bounded item used to define the view port into a game world. The Camera type is not transformable, but its bounds can be directly modified.


Example

// Assuming a Game object as 'game'
game.add('camera', new Foundation.Camera());

// Cameras can be centered on other bounded objects
game['camera'].centerOn(someTileOrSprite);


Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/actors/_digest.ts'
  • '/foundation/core/actors/Camera.ts'

Extends

This type extends:

If the boundToWorld property is true, an update() call will compensate for any movement which has moved the camera out of the bounds of the game singleton world.

Implements

This type does not implement any interfaces (except those in the base).


Public Properties

boundToWorld: boolean

  • If true, the camera's movement will not be allowed to go beyond the bounds of the game singleton world.
  • Corrections which enforce this behavior are applied in camera's update.

bounds: Rectangle

  • Returns a reference to the camera's bounding rectangle.

Constructors

public constructor(bounds: Rectangle, boundToWorld: boolean = true)

  • bounds define the camera's starting position (x, y) and dimensions (width and height). All component numbers refer to world units. I.e. a camera with bounds 0, 0, 800, 480 will be placed in the top-left corner of the world, and will show 800 by 480 world units.
  • See property explanation for boundToWorld. Defaults to true.

Instance Methods

public centerOn(b: {bounds: Rectangle}): void

  • Centers the camera on the bounds of b.