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

Author Topic: Rotating sprite around center  (Read 1340 times)

0 Members and 1 Guest are viewing this topic.

Munchor

  • Newbie
  • *
  • Posts: 16
    • View Profile
Rotating sprite around center
« on: July 24, 2013, 08:09:41 pm »
Hi,

I want to rotate my sprite around its center but I want it to be drawn with its origin as (0, 0). So I have this:

Code: [Select]
  setOrigin(texture.getSize().x / 2, texture.getSize().y / 2);
  rotate(-90);
  setOrigin(0, 0);

However, it does not seem to be working - the sprite is rotated exactly the same way as if I didn't have that first line. Any idea of what I'm doing wrong? I understand this might not be possible hence I'm posting here in the forums.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Rotating sprite around center
« Reply #1 on: July 24, 2013, 08:30:28 pm »
For sf::Transformable, the transforms are applied in a fixed order at rendering time -- the order of function calls is irrelevant.

If you need more flexibility, directly use the low-level API with sf::Transform.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: