Navigation
These archived docs are for Phaser 2.4.2 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser.Component. Health

new Health()

The Health component provides the ability for Game Objects to have a health property that can be damaged and reset through game code. Requires the LifeSpan component.

Source code: gameobjects/components/Health.js (Line 14)

Public Properties

damage

Damages the Game Object. This removes the given amount of health from the health property.

If health is taken below or is equal to zero then the kill method is called.

Source code: gameobjects/components/Health.js (Line 46)

heal

Heal the Game Object. This adds the given amount of health to the health property.

Source code: gameobjects/components/Health.js (Line 69)

health : number

The Game Objects health value. This is a handy property for setting and manipulating health on a Game Object.

It can be used in combination with the damage method or modified directly.

Default Value
  • 1
Source code: gameobjects/components/Health.js (Line 26)

maxHealth : number

The Game Objects maximum health value. This works in combination with the heal method to ensure the health value never exceeds the maximum.

Default Value
  • 100
Source code: gameobjects/components/Health.js (Line 35)