Skip to content

Commit bae732c

Browse files
committed
Merge pull request phaserjs#2027 from bsparks/dev
utilize the heal method
2 parents 0689395 + b7efb93 commit bae732c

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/gameobjects/components/LifeSpan.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Phaser.Component.LifeSpan.prototype = {
3838

3939
/**
4040
* A useful flag to control if the Game Object is alive or dead.
41-
*
41+
*
4242
* This is set automatically by the Health components `damage` method should the object run out of health.
4343
* Or you can toggle it via your game code.
44-
*
44+
*
4545
* This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates.
4646
* However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling.
4747
* @property {boolean} alive
@@ -51,12 +51,12 @@ Phaser.Component.LifeSpan.prototype = {
5151

5252
/**
5353
* The lifespan allows you to give a Game Object a lifespan in milliseconds.
54-
*
54+
*
5555
* Once the Game Object is 'born' you can set this to a positive value.
56-
*
56+
*
5757
* It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame.
5858
* When it reaches zero it will call the `kill` method.
59-
*
59+
*
6060
* Very handy for particles, bullets, collectibles, or any other short-lived entity.
6161
*
6262
* @property {number} lifespan
@@ -66,9 +66,9 @@ Phaser.Component.LifeSpan.prototype = {
6666

6767
/**
6868
* Brings a 'dead' Game Object back to life, optionally resetting its health value in the process.
69-
*
69+
*
7070
* A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true.
71-
*
71+
*
7272
* It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal.
7373
*
7474
* @method
@@ -82,10 +82,10 @@ Phaser.Component.LifeSpan.prototype = {
8282
this.alive = true;
8383
this.exists = true;
8484
this.visible = true;
85-
86-
if (typeof this.health === 'number')
85+
86+
if (typeof this.heal === 'function')
8787
{
88-
this.health = health;
88+
this.heal(health);
8989
}
9090

9191
if (this.events)
@@ -99,12 +99,12 @@ Phaser.Component.LifeSpan.prototype = {
9999

100100
/**
101101
* Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false.
102-
*
102+
*
103103
* It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal.
104-
*
105-
* Note that killing a Game Object is a way for you to quickly recycle it in an object pool,
104+
*
105+
* Note that killing a Game Object is a way for you to quickly recycle it in an object pool,
106106
* it doesn't destroy the object or free it up from memory.
107-
*
107+
*
108108
* If you don't need this Game Object any more you should call `destroy` instead.
109109
*
110110
* @method

0 commit comments

Comments
 (0)