sf::Sprite sprite; sprite.setOrigin(50, 50); // sets the origin to the center of the sprite
sf::Sprite sprite; sprite.setOrigin(sf::Vector2f(0, sprite.getLocalBounds().height)); // sets the origin to the bottom-left corner of the spriteThis example sets the origin of the sprite to the bottom-left corner. The origin is a Vector2f object, which takes in an x and y coordinate. In this case, the x coordinate is 0 and the y coordinate is the height of the sprite's local bounds (which is the bounding rectangle that encompasses the sprite). This means that any transformations applied to the sprite will be done around the bottom-left corner. Package Library: The SFML library provides the Sprite class and the setOrigin function.