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

Author Topic: How to rotate sprite, keeping the original position?  (Read 1512 times)

0 Members and 1 Guest are viewing this topic.

vechestva

  • Newbie
  • *
  • Posts: 25
    • View Profile
How to rotate sprite, keeping the original position?
« on: June 26, 2014, 11:45:08 pm »
How to rotate sprite, keeping the original position? Sprite position changes every time. It goes to ~ 300 degrees. :)
Sprite* square;
....
square->SetRotation((float)rand()%360);
 
I do not know much English.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to rotate sprite, keeping the original position?
« Reply #1 on: June 26, 2014, 11:50:16 pm »
What do you mean? If you just rotate it, its position won't change. Rotation and position are separate attributes. If you mean the visual position, of course it kind of changes when you rotate the sprite, but then I don't know what you mean with "keeping the original position". So please explain your problem better.
Laurent Gomila - SFML developer

vechestva

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: How to rotate sprite, keeping the original position?
« Reply #2 on: June 27, 2014, 12:17:25 am »
I want that it changed an angle on center. :P
I do not know much English.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: How to rotate sprite, keeping the original position?
« Reply #3 on: June 27, 2014, 12:54:16 am »
Your sprites rotates around its origin, which is by default in (0, 0) its top left corner. If you want it to rotate around its center, set its origin to its center. ;)