health(hp: number, maxHP?: number): HealthComp
Handles health related logic and events.const player = add([ health(3), ]) player.onCollide("bad", (bad) => { player.hurt(1) bad.hurt(1) }) player.onCollide("apple", () => { player.heal(1) }) player.on("hurt", () => { play("ouch") }) // triggers when hp reaches 0 player.on("death", () => { destroy(player) go("lose") })