# Rotating a sprite around a point, but keeping orientation the same

## Recommended Posts

I have a sprite that I need to move in an arc motion while still keeping it's orientation the same (so I can't use sprite.pivot and sprite.rotation AFAIK). So for example, if I have a sprite at 200,200 and it needs to pivot around a point at 200,400 for 90 degrees in a clockwise motion, it want it to end up at 400,400, with the sprite itself never having rotated during its journey.

Any ideas?

##### Share on other sites

sinus and cosinus ?

##### Share on other sites

sinus and cosinus ?

I could do the math to calculate every point on the circle, but I was hoping Phaser had an easier way to handle that...

Any other ideas?

##### Share on other sites

you could rotate the sprite around its own center, then translate it out from the center and then rotate it the other direction - this is how you would achieve this using linear algebra

or you could follow jerome's suggestion and just do the sin/cos math

the latter will be faster, in general, as you can optimize it for the fewest operations. but the former may be easier if you prefer linear algebra (vectors and matrices) solutions. personally I'd go with the latter - it's simpler and easier

##### Share on other sites

Hmm... It just seems odd that there's a easy way to move a sprite from point A to point B in a line without rotation of the sprite (using game.physics.velocityFromAngle), and an easy way to move a sprite in an arc with rotation (with sprite.pivot and sprite.rotation), but there's not an easy way to move a sprite in an arc without rotation...

Is this something that's addressed in Phaser 1.2?

(FYI: What I'm trying to accomplish is the equivalent of an animation of someone tossing a pizza box from offscreen, it comes in from the left edge (with the box parallel to the ground), moves downward in an arc, and stops when it hits the ground. I don't need need to have it adjust its orientation at all or even bounce when it hits the ground (yet)... I'm just trying to get the animation to work properly first.)