Phaser.Component.Health = function (){ } ; Phaser.Component.Health.prototype = { health: 1, maxHealth: 100, damage: function (amount){ if (this.alive) { this.health -= amount; if (this.health <= 0) { this.kill(); } } return this; } , setHealth: function (amount){ this.health = amount; if (this.health > this.maxHealth) { this.health = this.maxHealth; } return this; } , heal: function (amount){ if (this.alive) { this.health += amount; if (this.health > this.maxHealth) { this.health = this.maxHealth; } } return this; } } ;