API Docs for: 1.4.0
Show:

Kiwi.Camera Class

Defined in: src\core\Camera.ts:9
Module: Kiwi

A Camera is used to render a particular section of the game world on the stage. Each Camera has a coordinates which are held in the transform property, and a width/height. Note: This class should never be directly instantiated but instead should be made through a CameraManager's 'create' method.

Constructor

Kiwi.Camera

(
  • game
  • id
  • name
  • x
  • y
  • width
  • height
)
Kiwi.Camera

Parameters:

  • game Kiwi.Game

    The game that this camera belongs to.

  • id Number

    A unique ID for this camera

  • name String

    The name this camera goes by

  • x Number

    The x coordinate of the camera

  • y Number

    The y coordinate of the camera

  • width Number

    The width of the camera

  • height Number

    The cameras height

Returns:

Methods

_updatedStageSize

(
  • width
  • height
)
private

Updates the width/height of this camera. Is used when the stage resizes.

Parameters:

  • width Number

    The new width of the camera.

  • height Number

    The new height of the camera.

objType

() String public

The type of object this is.

Returns:

String:

"Camera"

render

() public

The render loop that is executed whilst the game is playing.

transformPoint

(
  • point
)
Kiwi.Geom.Point public

Convert from screen coordinates to world coordinates. Apply this camera's inverted matrix to an object with x and y properties representing a point and return the transformed point. Useful for calculating coordinates with the mouse.

Parameters:

Returns:

Kiwi.Geom.Point:

Transformed clone of the original Point.

transformPointToScreen

(
  • point
)
Kiwi.Geom.Point public

Defined in src\core\Camera.ts:203

Available since 1.2.0

Convert from world coordinates to screen coordinates. Useful for assessing visibility. Similar to "transformPoint", but in reverse.

Parameters:

Returns:

Kiwi.Geom.Point:

Transformed clone of the original Point.

update

() public

The update loop that is executed every frame.

Properties

_dirty

Boolean deprecated private

Defined in src\core\Camera.ts:147

Deprecated: As of 1.1.0, no use has been found for this property.

A flag that indicates whether this camera needs to be rendered again at the next update loop, or if nothing has changed so it doesn't.

_scratchMatrix

Kiwi.Geom.Matrix private

Defined in src\core\Camera.ts:170

Available since 1.3.1

Scratch matrix used in geometry calculations

_visible

Boolean private

Controls whether this Camera is rendered

dirty

Boolean deprecated public

Defined in src\core\Camera.ts:156

Deprecated: As of 1.1.0, no use has been found for this property.

A value used by components to control if the camera needs re-rendering.

fitToStage

Boolean public

If true then the camera will be resized to fit the stage when the stage is resized

Default: true

game

Kiwi.Game private

The game this Group belongs to

height

Number public

The height of this camera.

id

Number public

A unique identifier for this Layer within the game used internally by the framework. See the name property for a friendly version.

name

String public

A name for this Camera. This is not checked for uniqueness within the Game, but is very useful for debugging.

transform

Kiwi.Geom.Transform public

The Transform controls the location of the camera within the game world. Also controls the cameras scale and rotation.

visible

Boolean public

Controls whether this Camera is rendered.

width

Number public

The width of this camara.