I have a RectangleShape
sf::RectangleShape rect;
and I want it to continuously rotate around its own center.
When I use this code in the loop:
float rotation = rect.getRotation() + 1.0f;
if (rotation >= 360.0f) {
rotation = 0.0f;
}
rect.setRotation(rotation);
it rotates around its top left corner.
So I tried to alter its origin:
rect.setOrigin(rect.getSize().x * 0.5f, rect.getSize().y * 0.5f);
and now it does rotate around its center, but the center is now where its original top left corner was.
What am I doing wrong, please?