Skip to content
Isuru Kusumal Rajapakse edited this page Jun 18, 2017 · 1 revision

new Camera()

  • Represents a camera that captures a scene.
Returns
  • Void

Camera.constructor([id], target[, x=0, y=0, w=0, h=0])

Create an Camera.

Parameters
Name Type Description
id string - name of the Camera. Optional
target Scene - the scene the camera targted at.  
x=0 number - x position. Optional
y=0 number - y position. Optional
w=0 int - desired width. Optional
h=0 int - desired height. Optional
Returns
  • Void

Camera.targets(target)

targets the camera at the given scene

Parameters
Name Type Description
target Scene - the scene the camera targted at.  
Returns
  • Camera itself

Camera.tracks(object)

camera tracks the given object

Parameters
Name Type Description
object GameObject - the object the camera starts tracking.  
Returns
  • Camera itself

Camera.zoom(amount, keepRatio)

camera zooms in to, and keeps the constain ratio if enabled

Parameters
Name Type Description
amount int - amount to zoom in on.  
keepRatio bool - should the camera keep constent ratio while zooming.  
Returns
  • Camera itself

Camera.capture(c)

renders the containts within tha camera to the given canvas

Parameters
Name Type Description
c context - the canvas to draw the camera on.  
Returns
  • Void

Camera.absolute(relative)

converts camera relative position to absolute position

Parameters
Name Type Description
relative vector2 - position witin the camera.  
Returns
  • vector2 absolute - absolute position

Camera.relative(relative)

converts camera relative position to absolute position

Parameters
Name Type Description
relative vector2 - position witin the camera.  
Returns
  • vector2 absolute - absolute position

Camera.update()

updates the camera just once

Returns
  • Void

Camera.render(c)

renders the camera itself

Parameters
Name Type Description
c context - the canvas to draw the camera on.  
Returns
  • Void

Clone this wiki locally