SFML community forums

Help => Graphics => Topic started by: Mr. House on October 12, 2011, 03:16:21 am

Title: Changing center of rotation
Post by: Mr. House on October 12, 2011, 03:16:21 am
Hello,

I have a sprite that I would like to rotate around a point that is not the origin nor a point of the shape.

Here is a screenshot of my situation:

http://i.minus.com/ibt8ncX55ODhrh.png

I want that yellow sprite to rotate around the centerpoint of that circle like the Moon around the earth, so that the sprite follows the shape of the sectors.

I've tried messing around with the Sprite.SetCenter() methods but I'm not sure if what I'm doing is right.

Anyone have any wisdom on this matter? I'll post my code if needed. I'm using 1.6.
Title: Changing center of rotation
Post by: sbroadfoot90 on October 12, 2011, 07:54:07 am
yeah SetCenter() does what you need, you're just going to have to do some maths to work out exactly what parameters to pass to make it work how you want :)
Title: Changing center of rotation
Post by: Mr. House on October 12, 2011, 10:16:55 pm
It doesn't seem to though. I used SetCenter(50,50) but it doesn't place it at point (50,50). I don't get it :/

Would you like me to post my code and see if you can offer me a solution?
Title: Changing center of rotation
Post by: sbroadfoot90 on October 12, 2011, 11:37:50 pm
yeah that would be helpful. also upload the image you are rotating as well as its dimensions
Title: Changing center of rotation
Post by: Mr. House on October 12, 2011, 11:44:07 pm
Nevermind, I figured it out.
Title: Changing center of rotation
Post by: Gazonga on January 28, 2012, 09:59:23 pm
You wouldn't mind posting how you solved it?
I'm having similar problems ;/
Title: Changing center of rotation
Post by: TechRogue on January 30, 2012, 03:38:04 am
What's the problem you're having? We might be able to help.