thiagoprzy Posted February 18, 2015 Share Posted February 18, 2015 Hello, everyone. First of all, sorry if this is a duplicated topic, but I couldn't find one that was exactly what I needed. I have one sprite (let's call it "bullet") and another sprite that represents its shadow. At first I was only instantiating both, using the same starting position and velocity.x. The problem is that, after some changes in the code, I realized that I should remove both when the bullet collides with a particular object. Both bullet and shadow are part of a group (lots of bullets and shadows!), and I needed something to kill both in case of bullet colision, and also to not depend on two "setValue" for their velocity (if "bullet" is velocity.x - 300, then the shadow would follow it). Is there some way to do it in Phaser? Just one thing: I found some places where you could use "addChild", but I couldn't make it work. If this is the case, could you please show me a practical example? Thank you so much in advance. Link to comment Share on other sites More sharing options...
ptdnet Posted February 18, 2015 Share Posted February 18, 2015 addChild should be exactly what you want. I'm using it, for instance, to put health bars on units. Alternately, you can have each "bullet" be a group containing two sprites inside it.var bullet = game.add.group();bullet.create(0, 0, "shadowSprite");bullet.create(0, 0, "bulletSprite"); Link to comment Share on other sites More sharing options...
Recommended Posts