Nikow Posted May 13, 2015 Share Posted May 13, 2015 Hi ! I'm creating a space shooter, and i would like the asteroids can't be explode with only one shoot.. So, how could i assign differents life values to my sprites (asteroids sprites) ti make them destructables at differents points ? Thank you ! Link to comment Share on other sites More sharing options...
drhayes Posted May 13, 2015 Share Posted May 13, 2015 It depends on how you're creating your sprites, but I'm pretty sure sprites have a health property you can modify and decrement when they're shot using the damage method. If not, you might have to derive your own Asteroid sprite class and mixin the Health component. Link to comment Share on other sites More sharing options...
Nikow Posted May 13, 2015 Author Share Posted May 13, 2015 I m creating them with te classic way of phaser Link to comment Share on other sites More sharing options...
drhayes Posted May 13, 2015 Share Posted May 13, 2015 Check out the extending sprites demo. It shows how to subclass a sprite so you can customize its behavior. Link to comment Share on other sites More sharing options...
Nikow Posted May 14, 2015 Author Share Posted May 14, 2015 Perfect ! Thank you ! Link to comment Share on other sites More sharing options...
Nikow Posted May 15, 2015 Author Share Posted May 15, 2015 Just a little precision, if i want to create my extending class on a separate file, how can i include it ? Link to comment Share on other sites More sharing options...
drhayes Posted May 15, 2015 Share Posted May 15, 2015 It depends if you're using JavaScript, or TypeScript, or what. I'm not sure what your setup is, there. Link to comment Share on other sites More sharing options...
Nikow Posted May 15, 2015 Author Share Posted May 15, 2015 I'm coding in Js Link to comment Share on other sites More sharing options...
drhayes Posted May 15, 2015 Share Posted May 15, 2015 The file declaring your parent needs to come before the file declaring your child. Link to comment Share on other sites More sharing options...
Recommended Posts