So I'm trying to work with the origin, and it makes no sense to me at all. Here's some simple code I wrote to play around with the origin:
sf::RenderWindow window(sf::VideoMode(1200, 800), "Window");
sf::RectangleShape square(sf::Vector2f(200, 200));
square.setPosition(500, 600);
auto smallSquare = square;
smallSquare.move(0, -square.getSize().y);
smallSquare.setOrigin(0, square.getSize().y);
smallSquare.scale(0.5, 0.5);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.draw(square);
window.draw(smallSquare);
window.display();
}
What I expect this to do is
1) Draw a 200x200 square at the center bottom of the screen
2) Make a copy of that square called smallSquare
3) Move the smallSquare upwards by the height of the square
4) Set smallSquare's origin to it's bottom left corner, instead of top left.
5) Scale the smallSquare to 0.5 around it's new origin
So the result should be a 200x200 square at the center bottom, with a 100x100 square on top of it on it's left side. Sort of like a blocky lowercase b shape.
Instead what I get is
Why is this happening? What's wrong with my assumptions of how the origin works?