area(opt?: AreaCompOpt): AreaComp
Attach a collider area from shape and enables collision detection in a Game Object.
param
opt- Options for the area component. See
// Automatically generate area information from the shape of render
const player = add([
sprite("bean"),
area(),
])
// Die if player collides with another game obj with tag "tree"
player.onCollide("tree", () => {
destroy(player)
go("lose")
})
// Check for collision manually every frame instead of registering an event
player.onUpdate(() => {
if (player.isColliding(bomb)) {
score += 1
}
})
returns
The area comp.
since
v2000.0
group
Components