Interface

HealthComp

:

The health component.

group Component Types

hp

: number

Current health points. Setting it to a lower or higher value will trigger onHurt() and onHeal(). Setting it to a value greater than maxHP will set it to maxHP. Setting it to a value less than 0 will set it to 0 and trigger onDeath().

maxHP

: number

Max amount of HP.

dead

: boolean

Whether hp is 0.

onHurt

(action: (deltaHP?: number) => void): KEventController

Register an event that runs when the hp is lowered.

since v2000.1

onHeal

(action: (deltaHP?: number) => void): KEventController

Register an event that runs when the hp is increased.

since v2000.1

onDeath

(action: () => void): KEventController

Register an event that runs when object's HP becomes zero.

since v2000.1

kaplay logo

Layer

Miscalenous