Jump to content

Can I change the point of rotation on a sprite without affecting its position?


LandonSchropp
 Share

Recommended Posts

I would like to change the point a sprite rotates around to the center of the sprite. I realize I can do this by calling sprite.anchor.set(0.5), but that also effectively changes the position of the sprite. Is there a way to change the rotation point of the sprite without affecting its position? I found the pivot property, but it also seems to have the same problem.

Link to comment
Share on other sites

Not sure if that's what you a re looking for, but if I want to change the anchor and keep position the same, I do something like this:

sprite.anchor.set(0.5,0.5);
sprite.x += sprite.width*0.5;
sprite.y += sprite.height*0.5;

You are moving the sprite's position the amount of space it needs to stay in the exact same place, but with the new anchor.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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