Module camera

An interface for modifying how a Scene is projected to the player.

A Camera is an implicit property of Scene. You shouldn't have to create one yourself.

Camera extends BoundObject

Properties

focal An {x, y} vector for the tracking center of the camera in pixels.
max_scale Maximum scale the camera will zoom in to.
min_scale Minimum scale a camera will zoom out to.
rotation The angle of the Camera in radians.
scale The zoom factor of the Camera.
lerp The lerp factor of the Camera.
screen_size (read only) An {x, y} vector of the screen size in pixels.
snap_to_scene (bool) Whether the camera should stop panning at the edge of the Scene.
translation An {x, y} vector of the translation offset from focal in pixels.

Instance Methods

camera:track_entities (...) Provide a list of Entities for the camera to track.
camera:snap_tracking () Force the camera to its destination position, ignoring lerp .


Properties

Properties. Significant fields on an instance.
focal
An {x, y} vector for the tracking center of the camera in pixels. This is set automatically in single and multiple mode.

see also:

max_scale
Maximum scale the camera will zoom in to.
min_scale
Minimum scale a camera will zoom out to.
rotation
The angle of the Camera in radians.

A positive value rotates it clockwise, a negative value counterclockwise. Remember that this is the camera's rotation, so the Scene will appear to rotate in the opposite direction.

Default is 0.

scale
The zoom factor of the Camera.

1 means 1:1 pixel ratio with the screen. Greater than 1.0 means zoom in. Less than 1.0 means zoom out.

Minimum is 0. Default is 1.

lerp
The lerp factor of the Camera. This controls how smoothly the Camera approaches a new focal and scale over time.

1 means instantly, 0 means the camera stays stationary. 0.5 means the camera moves half the distance between its current point and the destination point every frame.

Minimum is 0. Maximum is 1. Default is 1.

screen_size
(read only) An {x, y} vector of the screen size in pixels.
snap_to_scene
(bool) Whether the camera should stop panning at the edge of the Scene.

Default is true

Warning: This is ignored in multiple mode.

translation
An {x, y} vector of the translation offset from focal in pixels.

This is completely independent of focal . For example, it could be animated with an Easer to create an earthquake effect.

Instance Methods

Instance Methods. Must be called on an instance of Class. e.g. instance:method("foo")
camera:track_entities (...)
Provide a list of Entities for the camera to track.

This works in three modes:

nil - Free mode. The camera does not move unless controlled manually.

Entity - Single mode. The camera pans to keep entity in view.

Entity, Entity, ... - Multiple mode. The camera pans and zooms to keep them all in view.

Parameters:

camera:snap_tracking ()
Force the camera to its destination position, ignoring lerp .
generated by LDoc 1.3.12