Collider
ctx.collider provides collider queries for the current GameObject.
The current object should have a Collider component. Targets that participate in collision should also have Collider components.
ctx.collider.bounds()
ts
ctx.collider.bounds(): BoundsReturns the world bounds of the current object's Collider.
js
const box = ctx.collider.bounds()
if (box.y > ctx.project.height) {
ctx.node.destroy()
}Rules:
- The current object must have a Collider.
- This is Tissue collider bounds, not Phaser sprite bounds.
ctx.collider.overlaps(target)
ts
ctx.collider.overlaps(target: string | SceneObject): booleanChecks whether the current Collider overlaps one target.
js
if (ctx.collider.overlaps('Ground')) {
ctx.state.gameOver = true
}Rules:
- Target must exist.
- Target should have a Collider.
- Avoid fixed names for many repeated prefab instances.
ctx.collider.overlapsAll(names)
ts
ctx.collider.overlapsAll(names: string[]): SceneObject[]Checks a small fixed list of target names or ids and returns all hits.
js
const hits = ctx.collider.overlapsAll(['TopPipe', 'BottomPipe'])
if (hits.length > 0) {
ctx.state.dead = true
}Rules:
- Every name must exist or project lint will fail.
- Returns an array. Check
.length > 0. - Use it for small fixed target lists.
ctx.collider.overlapsGroup(tag)
ts
ctx.collider.overlapsGroup(tag: string): SceneObject[]Checks all objects with the given tag and returns all hits. This is preferred for repeated prefab instances such as pipes, enemies, or bullets.
js
const hits = ctx.collider.overlapsGroup('pipe')
if (hits.length > 0) {
ctx.state.dead = true
}Prefab children should explicit