view
The shared "what does the 2D camera see right now" record for the twoDKit: the centre of the view, its half width and half height in world units (tiles) and the pixel zoom. `twoDKit.Camera2D` publishes it every frame; parallax backgrounds and anything else that frames or culls by…
view
The shared "what does the 2D camera see right now" record for the twoDKit: the centre of the view, its half width and half height in world units (tiles) and the pixel zoom. twoDKit.Camera2D publishes it every frame; parallax backgrounds and anything else that frames or culls by the camera reads it.
When no Camera2D has published in the last quarter second (edit mode, or a different camera is in charge), current() falls back to the first camera the engine's camera.list tool reports, re-read at most four times a second: its position, and its orthoHeight when orthographic (otherwise a view 16 tiles tall), with the width taken from the viewport's aspect.
Everything here is local to this peer; nothing is synced.
API
View.publish(x, y, halfW, halfH, zoom): record the view this frame. Camera2D calls it; call it yourself only if you write your own 2D camera.View.current(): State: the latest view:{ x, y, halfW, halfH, zoom, frame }(frameis theos.clock()time it was taken).
local View = require("twoDKit.view")
local v = View.current()
local onScreen = math.abs(px - v.x) < v.halfW and math.abs(py - v.y) < v.halfH
In the kit
Written by Camera2D, read by Level2D to drive and show only the parallax background of the level the view is in (see twoDKit.parallax).
Scoped to this part · feeds back into the world's score.