Skip to content

Camera

const camera = require("@vectarine/camera")
camera.new(): Camera2

Create a new camera for 2D A camera represents a transformation between the game world and the screen

Returns Camera

export type Camera2 = ...
Camera2:screen(point: Vec.Vec2): Vec.Vec2

Get the screen position of a point in the world

Parameters

Returns Vec2

Camera2:screenFastlist(point: Fastlist.FastList): Fastlist.FastList

The fastlist version of Camera:screen()

Parameters

Returns FastList

Camera2:world(point: Vec.Vec2): Vec.Vec2

Get the world position of a point on the screen

Parameters

Returns Vec2 | FastList

Camera2:worldFastlist(point: Fastlist.FastList): Fastlist.FastList

The fastlist version of Camera:world()

Parameters

Returns FastList

Camera2:isVisible(point: Vec.Vec2): boolean

Check if a point is visible on the screen

Parameters

Returns boolean

Camera2:moveTowards(point: Vec.Vec2, amount: number): ()

Move the camera towards a point by a certain amount. If called every frame, you should keep amount small, like 0.01 This is the same as: Camera.position = Camera.position + (point - Camera.position):scale(amount)

Parameters

  • point (Vec.Vec2): Vec2
  • amount (number): number
Camera2:rotateTowards(angle: number, amount: number): ()

Rotate the camera towards an angle by a certain amount. If called every frame, you should keep amount small, like 0.01

Parameters

  • angle (number): number
  • amount (number): number
Camera2:zoomTowards(zoom: number, amount: number): ()

Zoom the camera towards a zoom level by a certain amount. If called every frame, you should keep amount small, like 0.01

Parameters

  • zoom (number): number
  • amount (number): number