Skip to content
Download

Camera

Each room has a camera, configured in the room Inspector. In code it is camera (Lua) or scene().camera (C++).

function onSpawn(self)
camera.follow(self)
camera.smoothing = 4
camera.bounded = true
self:onTouchStart("Enemy", function() camera.shake(3, 0.2) end)
end
Property What it is
x, y Top-left corner of the visible area, in world coordinates.
zoom World magnification (1 = no zoom). The interface and onRenderGui are not magnified.
bounded true = while following a target, the camera does not leave the room.
smoothing From 0 to 10. 0 sticks to the target.
deadzoneW, deadzoneH Size of the central rectangle in which the target moves without moving the camera.
Function What it does
follow(instance) Starts following an instance, centering on it on the first frame.
stopFollowing() Stops following; the camera stays where it is.
shake(force, seconds) Shakes the screen, up to force pixels each way, fading until it stops.

C++: follow takes a Handle; handle() returns that of the instance itself.