FlxObject
has a built-in health
property which can be used for tracking and object’s health. If you use FlxObject.hurt()
and cause the object’s health to reach 0
, it will call FlxObject.kill()
on the object.
// set object's health to 5
object.health = 5;
// hurt the object for 2
object.hurt(2);