Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: rotating a sprite on the center of the image  (Read 2069 times)

0 Members and 2 Guests are viewing this topic.

pfox

  • Newbie
  • *
  • Posts: 2
    • View Profile
rotating a sprite on the center of the image
« on: June 25, 2009, 07:33:55 pm »
hi.. i have a sf::Sprite that i'm trying to rotate, but whenever it rotates, it rotates it based off of where the center of the sprite is via SetCenter(). But this also affects where the origin of the sf::Image for the sprite is rendered.. This seems like it would be a pretty common issue, and I'm curious if anyone has a solution/recipe for this?

Basically, if I have a sprite with a circle/wheel image for it, I want that wheel to "spin" in place and not actually "fly around in circles" based off of the origin of the image, relative to it's sprite (as seems to be the default case)

I imagine the solution involves changing the center of the sprite every time you SetRotation(), I just don't know the math involved. Is there a better way? Am I thinking about this problem the wrong way?

Any help would be greatly appreciated, thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
rotating a sprite on the center of the image
« Reply #1 on: June 25, 2009, 07:38:55 pm »
Just set the center of the sprite to be its actual center (do it once), and that's it.
Laurent Gomila - SFML developer

pfox

  • Newbie
  • *
  • Posts: 2
    • View Profile
rotating a sprite on the center of the image
« Reply #2 on: June 25, 2009, 07:43:35 pm »
Thank you very much for the quick reply.. I managed to get it working (stupid n00b mistake on my part).

It's a great library. Thanks again!