dandorf Posted October 22, 2014 Report Share Posted October 22, 2014 I created a group with the enemies on the screen. Now I would like to have each enemy hit points (some 2 others 3 others 4, etc ...). Then I thought that if there is way to make a kind of stretched groups phaser (and that he extended class could add a variable to the health points of each enemy ..?) Or do inthe Sprite class phaser .... I do not know how I should approach this. Any help or ideas? Thanks. Quote Link to comment Share on other sites More sharing options...
lewster32 Posted October 22, 2014 Report Share Posted October 22, 2014 Sprites already have a health property which you could probably use, though oftentimes it's better to create your own and manage it yourself. Extending Sprite is definitely the way to go. I'd definitely keep the hit points on the Sprites (or extended Sprite objects) and not the group, as the hit points count belongs to the enemies. Quote Link to comment Share on other sites More sharing options...
dandorf Posted October 22, 2014 Author Report Share Posted October 22, 2014 I think I finally have to make the extended class Sprite. What I can do in my game code itself, or I have to do it in the file "phaser.js"? If I can do in my own game code ... How I can do? Thank you very much for the help. Quote Link to comment Share on other sites More sharing options...
lewster32 Posted October 22, 2014 Report Share Posted October 22, 2014 There's an example of how to extend Sprite - you shouldn't edit phaser.js, just put this in your own file structure - usually with the rest of your game before the game code itself: http://examples.phaser.io/_site/view_full.html?d=sprites&f=extending+sprite+demo+1.js&t=extending%20sprite%20demo%201 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.