collision — Luau Binding
require("collision"): enrol targets, subscribe to overlap events, and query the scene. The programmatic surface of the collision system — detection and queries only; the response is your code. Every function is [antos].
Status: design. Not built yet. Signatures are the intended surface, settled against the collision model.
local collision = require("collision")
Enrol
| Call |
Returns |
Does |
collision.watch(target, opts?) |
ok |
enrol target for collision. opts = { shape = "aabb" / "circle", layer = 0, mask = ~0 } — shape taken from the target's size, layer the group it sits on, mask the layers it tests against |
collision.unwatch(target) |
ok |
remove a target from collision testing |
Events
| Call |
Returns |
Does |
collision.on(kind, handler) |
sub |
subscribe to "enter" / "stay" / "exit"; handler(a, b) runs in the stage's React phase. Returns a handle to unsubscribe |
collision.off(sub) |
ok |
unsubscribe |
Query
| Call |
Returns |
Does |
collision.overlapping(a, b) |
bool |
do a and b overlap this frame — an immediate test, no subscription |
collision.at(x, y, layer?) |
list |
targets whose bound contains the point (optionally on a layer) |
collision.query(shape, layer?) |
list |
targets overlapping a region |
collision.pairs() |
list |
every overlapping pair this frame |
local collision = require("collision")
local tween = require("tween")
collision.watch(player, { layer = 1, mask = WALLS | PICKUPS })
collision.on("enter", function(a, b) -- the policy is ours, not the engine's
if b.layer == PICKUPS then
score += 10
tween.to(b, { alpha = 0, scale = 0 }, { duration = 0.3 }) -- collect animation
end
end)
Where to go next
- Detection, bounds, layers, and the response / physics split → collision
- The substrate — phase order, event delivery → stage
- The movement siblings → motion · tween