Skip to content

Commit 0b82a68

Browse files
committed
Merge pull request phaserjs#1794 from stephandesouza/patch-1
Add a Heal Method to Phaser.Components.Health
2 parents a7a7455 + cb89b9c commit 0b82a68

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/gameobjects/components/Health.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ Phaser.Component.Health.prototype = {
4747

4848
return this;
4949

50+
},
51+
52+
/**
53+
* Heal the Game Object. This adds the given amount of health from the `health` property.
54+
*
55+
* @member
56+
* @param {number} amount - The amount to add from the current `health` value.
57+
* @return {Phaser.Sprite} This instance.
58+
*/
59+
heal: function(amount) {
60+
61+
if (this.alive)
62+
{
63+
this.health += amount;
64+
}
65+
66+
return this;
67+
5068
}
5169

5270
};

0 commit comments

Comments
 (0)