Jump to content

Rotate 3 sprites around a sprite


sdgsgsdfgfdg
 Share

Recommended Posts

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

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

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 :D

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...