Kiwi.Camera Class
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
Parameters:
-
game
Kiwi.GameThe game that this camera belongs to.
-
id
NumberA unique ID for this camera
-
name
StringThe name this camera goes by
-
x
NumberThe x coordinate of the camera
-
y
NumberThe y coordinate of the camera
-
width
NumberThe width of the camera
-
height
NumberThe cameras height
Returns:
Item Index
Methods
_updatedStageSize
-
width
-
height
Updates the width/height of this camera. Is used when the stage resizes.
Parameters:
-
width
NumberThe new width of the camera.
-
height
NumberThe new height of the camera.
objType
()
String
public
The type of object this is.
Returns:
"Camera"
render
()
public
The render loop that is executed whilst the game is playing.
transformPoint
-
point
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:
-
point
Kiwi.Geom.Point
Returns:
Transformed clone of the original Point.
transformPointToScreen
-
point
Convert from world coordinates to screen coordinates. Useful for assessing visibility. Similar to "transformPoint", but in reverse.
Parameters:
-
point
Kiwi.Geom.Point
Returns:
Transformed clone of the original Point.
update
()
public
The update loop that is executed every frame.
Properties
_dirty
Boolean
deprecated
private
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.
_visible
Boolean
private
Controls whether this Camera is rendered
dirty
Boolean
deprecated
public
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
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.