sdgsgsdfgfdg Posted November 11, 2015 Share Posted November 11, 2015 asdf Link to comment Share on other sites More sharing options...
in mono Posted November 11, 2015 Share Posted November 11, 2015 Maybe set their anchors outside of their bounds. You can do that by setting either anchor.x or anchor.y of a sprite to a value larger than 1 or smaller than 0, e.g. sprite.anchor.set(0.5, -1) will center the anchor along x and place it outside the sprite (one height away). Link to comment Share on other sites More sharing options...
Skeptron Posted November 11, 2015 Share Posted November 11, 2015 Here I did it with 2 orbs, you could apply the same strategy for 3 : http://phaser.io/sandbox/edit/ldundtvm Could probably be improved. drhayes and shohan4556 2 Link to comment Share on other sites More sharing options...
YuShaN Posted November 11, 2015 Share Posted November 11, 2015 This is my codehttp://phaser.io/sandbox/edit/guaKvyJL shohan4556 1 Link to comment Share on other sites More sharing options...
Skeptron Posted November 11, 2015 Share Posted November 11, 2015 Issue with your code is that if the main sprite moves, others won't follow. Or you would have to redefine all the coordinates each time in the update() function. Using a sprite and child has this advantage : if the main sprite moves or rotates etc. the children will do the same. Your calculation of the angles is far better though. Link to comment Share on other sites More sharing options...
YuShaN Posted November 11, 2015 Share Posted November 11, 2015 Issue with your code is that if the main sprite moves, others won't follow. Or you would have to redefine all the coordinates each time in the update() function. Using a sprite and child has this advantage : if the main sprite moves or rotates etc. the children will do the same. Your calculation of the angles is far better though. Just replace 300 by player0.x and player.y Link to comment Share on other sites More sharing options...
Skeptron Posted November 11, 2015 Share Posted November 11, 2015 It's not just about the coordinates, it's about the 'orbs' being tied to their parent. What if I destroy the sprite because the player has been shot at? You will instantly get an exception because player0 doesn't exist, thus player0.x will throw.Or what if my sprite must be invisible for a period of time? With your code we would still see the orbs, unless you add code in the update() function (which will start to be huge). With my implementation, just do sprite.visible = false and you won't see the child orbs. Etc. Using children seems more legit, even though your example works perfectly (for this particular scope). Link to comment Share on other sites More sharing options...
sdgsgsdfgfdg Posted November 11, 2015 Author Share Posted November 11, 2015 asdf Link to comment Share on other sites More sharing options...
Recommended Posts