Jump to content

Accessing and changing properties on the Sprite Object


asc3ndpony
 Share

Recommended Posts

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

  • 2 years later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...