Skip to content
tjakka5 edited this page Dec 6, 2016 · 2 revisions

The Camera controls how and where Models are drawn on the screen. It is pretty minimal, but gets the job done.


Moves the camera by dx, dy.

Camera:move(dx, dy)


Sets the camera position to x, y.

Camera:moveTo(x, y)


Rotates the camera by r.

Camera:rotate(r)


Sets the camera rotation to r.

Camera:rotateTo(r)


Zooms the camera by s.

Camera:zoom(s)


Sets the camera scale to s.

Camera:zoomTo(s)


Updates internal rotation values. Updates automatically. Camera:updateRotations()


Returns the bounding box of the camera.

x, y, w, h = Camera:getBoundingBox()


Translates world coordinates to screen coordinates.

x, y = Camera:worldToScreen(x, y, z)


Translates screen coordinates to world coordinates (z is 0).

x, y, z = Camera:screenToWorld(x, y)


Adds a model to the z-buffer.

Camera:draw(model, depth)


Updates the camera's size. Call this in love.resize.

Camera:resize(w, h)


Draws all the models on the screen and clears the z-buffer afterwards.

Camera:render()


Internal function. Draws a model to the screen without going trough the z-buffer.

Camera.renderModel(model, Camera)

Clone this wiki locally