asc3ndpony Posted December 28, 2015 Share Posted December 28, 2015 Hi Phaser users, I've been using Phaser for about three weeks and have hit my first wall. I'm making a 2d fighting game and while I have basic attacks working, Phaser apparently kills the sprite on collision with an attack. I'm wanting to set a fixed amount of health so that instead of instantly killing the sprite, the game subtracts the health from the sprite. My sprite names are "player" and "player2", and when I went to the Chrome console, I typed in player and noticed that the player object inherits from Phaser.Sprite. I saw there were already properties in the Phaser.Sprite object that I think would be useful, such as health and damage. I saw in the API they're listed under the Phaser.Component section, but I didn't see any example under the Examples tag that used them. How would I go about using these properties with my "player" and "player2" sprites? Any help you can provide is greatly appreciated. Link to comment Share on other sites More sharing options...
lewster32 Posted December 29, 2015 Share Posted December 29, 2015 I believe it's simply a matter of setting the sprite's health property, then calling damage(amount) each time you want to do damage. When the health gets to 0 the sprite is killed. You can see all of the health-related stuff in this component. Link to comment Share on other sites More sharing options...
n7pankake Posted January 11, 2018 Share Posted January 11, 2018 Link to comment Share on other sites More sharing options...
Recommended Posts