Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/tiny-engine/llms.txt
Use this file to discover all available pages before exploring further.
Collider registers a geometric shape with the engine’s collision system and fires events when it starts overlapping, continues overlapping, or stops overlapping another collider. Shapes are either axis-aligned rectangles or circles, and collision filtering is controlled by two string-array props — group (what this collider is) and collidesWith (what it detects).
Collider extends Node2D, so its position is inherited from parent Transform nodes in the scene tree.
Usage
Props
The collision geometry. Create one with
shapes.rectangle(width, height) or shapes.circle(radius). The shape is set at construction and cannot be changed afterwards.The groups this collider belongs to. Other colliders whose
collidesWith contains any of these strings will detect this collider. Must be set at construction — immutable after that.The groups this collider actively checks against. Must be set at construction — immutable after that.
Local position offset from the parent node. Useful for aligning the collision shape with a sprite that is not centered at the origin.
A ref created by
useRefNode(PrimaryNode.Collider). Use it to call methods or inspect state on the collider at runtime.Optional node identifier. Must match
[a-zA-Z][a-zA-Z0-9-_]* when a string.Draw order among siblings. Defaults to
0.Events
Subscribe withuseEvent. Each callback receives the other Collider instance.
| Event name | Callback signature | Description |
|---|---|---|
colliderEntered | (other: Collider) => void | Fires once on the first frame two colliders overlap. |
collided | (other: Collider) => void | Fires every frame while two colliders keep overlapping. |
colliderExited | (other: Collider) => void | Fires once on the frame the overlap ends. |
started | () => void | Fires once after the collider registers with the system. |
updated | (delta: number) => void | Fires every frame during the update cycle. |
drawed | (delta: number) => void | Fires every frame during the draw cycle. |
destroyed | () => void | Fires once when the node is removed. |
Runtime properties
| Property | Type | Description |
|---|---|---|
shape | Shape | Read-only. The collision geometry set at construction. |
group | Set<string> | Read-only. Groups this collider belongs to. |
collidesWith | Set<string> | Read-only. Groups this collider checks against. |
size | Vector2 | Read-only. Bounding dimensions (diameter for circles). |
globalPosition | Vector2 | World-space position inherited from parent transforms. |
Debug visualisation
SettestOptions.showColliders = true in your GameConfig to draw shapes as semi-transparent blue overlays at runtime. Rectangle colliders draw from the node’s top-left position.
Complete example — enemy takes damage
group and collidesWith are converted to Set<string> at construction time and cannot be modified afterwards. Design your group names upfront.Related
- Collision guide — shapes, groups, spatial hashing, and resolve patterns
RayCast— line-based detection that queries collider groupsTransform— position the collider in world spaceuseEvent— subscribe to collision events