Camera
const camera = require("@vectarine/camera")Functions
Section titled “Functions”camera.new
Section titled “camera.new”camera.new(): Camera2Create a new camera for 2D A camera represents a transformation between the game world and the screen
Returns Camera
Camera2
Section titled “Camera2”export type Camera2 = ...Camera2:screen
Section titled “Camera2:screen”Camera2:screen(point: Vec.Vec2): Vec.Vec2Get the screen position of a point in the world
Parameters
point(Vec.Vec2): Vec2
Returns Vec2
Camera2:screenFastlist
Section titled “Camera2:screenFastlist”Camera2:screenFastlist(point: Fastlist.FastList): Fastlist.FastListThe fastlist version of Camera:screen()
Parameters
point(Fastlist.FastList): FastList
Returns FastList
Camera2:world
Section titled “Camera2:world”Camera2:world(point: Vec.Vec2): Vec.Vec2Get the world position of a point on the screen
Parameters
point(Vec.Vec2): Vec2 | FastList
Returns Vec2 | FastList
Camera2:worldFastlist
Section titled “Camera2:worldFastlist”Camera2:worldFastlist(point: Fastlist.FastList): Fastlist.FastListThe fastlist version of Camera:world()
Parameters
point(Fastlist.FastList): FastList
Returns FastList
Camera2:isVisible
Section titled “Camera2:isVisible”Camera2:isVisible(point: Vec.Vec2): booleanCheck if a point is visible on the screen
Parameters
point(Vec.Vec2): Vec2
Returns boolean
Camera2:moveTowards
Section titled “Camera2:moveTowards”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): Vec2amount(number): number
Camera2:rotateTowards
Section titled “Camera2:rotateTowards”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): numberamount(number): number
Camera2:zoomTowards
Section titled “Camera2:zoomTowards”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): numberamount(number): number
