Zalon Posted June 24, 2014 Share Posted June 24, 2014 Hello, I've been playing around with the asteroids movement from the phaser examples. I then decided that I would try to recreate the example with a group instead of a single sprite, so I would have a ship base with 2 attached wings. However, since a group doesn't have a body, there is no way to move the group using acceleration and angularVelocity. If I instead move the parts, the group coordinates will not follow, so how would I go about creating the same kind of movement for a group? Link to comment Share on other sites More sharing options...
lewster32 Posted June 25, 2014 Share Posted June 25, 2014 Groups can't have bodies, but sprites can, and you can add things to sprites using addChild - so you can do it this way:var ship = game.add.sprite(0, 0, 'ship');var leftWing = game.add.image(0, 0, 'leftwing');leftWing.anchor.x = 1; // anchor the left wing from the right-hand sidevar rightWing = game.add.image(0, 0, 'rightwing');ship.addChild(leftWing);ship.addChild(rightWing);game.physics.arcade.enable(ship); mtburdon and Zalon 2 Link to comment Share on other sites More sharing options...
Zalon Posted June 26, 2014 Author Share Posted June 26, 2014 Yes, thank you... addChild works perfect for what I want to do lewster32 1 Link to comment Share on other sites More sharing options...
Zalon Posted July 5, 2014 Author Share Posted July 5, 2014 With groups you are able to move child objects with moveDown/moveUpUsing, however using this method, the child sprites will be on top of the parent, how do i move the parent to the top? Link to comment Share on other sites More sharing options...
lewster32 Posted July 5, 2014 Share Posted July 5, 2014 I don't think you can - however you can create a blank sprite and then put things in it and reorder them as needed:var container = game.add.sprite(0, 0);var ship = game.add.image(0, 0, 'ship');var leftWing = game.add.image(0, 0, 'leftWing');var rightWing = game.add.image(0, 0, 'rightWing');container.addChild(leftWing);container.addChild(rightWing);container.addChild(ship); Link to comment Share on other sites More sharing options...
Zalon Posted July 6, 2014 Author Share Posted July 6, 2014 Ok thanks, I'll try that Good to have you around Lewster32, to help me with all my n00b questions Link to comment Share on other sites More sharing options...
Recommended Posts