SFML community forums
Help => Graphics => Topic started by: Sakurazaki on June 04, 2013, 02:35:24 am
-
Hello,
I've got a sf::Sprite which I initialise with setOrigin instead of setPosition.
When I try to draw it to renderwindow, despite everything (origin and pos) are the correct,
the texture is drawn in top left corner (0, 0).
Is there something I'd to know when drawing sprites with setOrigin?
thanks!
-
Uh? Are you using setOrigin as a substitute for setPosition?
-
What do you do exactly?
-
I've got a Sprite which on resizing move's his origin.
I want to set its center in order to don't make it move when resizing, so I set his origin to his position
and then resize it.
Am I doing it wrong?
-
If the origin is set to the point that mustn't move, you shouldn't have to change it everytime the sprite is resized.
-
I don't change it. I CREATE the sprite with a position and a origin, and then resize it.
I've read the tutorial in here:
http://www.sfml-dev.org/tutorials/2.0/graphics-transform.php
But I'm sure I didn't understand how origin and scale work :/
-
so I set his origin to his position
Don't forget that the origin is relative to your sprite. If your image is 50x50 and you want the origin in the center of it then set it to (25, 25), even if the sprite has e.g. position (100, 100).
Is that what you were doing wrong?
If not then you should provide a small example code so that it is clear what you are doing.
-
I've got a Sprite which on resizing move's his origin.
I don't change it. I CREATE the sprite with a position and a origin, and then resize it.
This is not clear :P
The origin is the point (in local coordinates!) that never changes when you apply transformations to your sprite. So, for example, if your sprite is a character, the origin will most likely be the bottom-middle point (under its feet), so that when resized it grows up but not down. And equally on the left and right.
You should describe precisely what you do (what kind of sprite you have, where is the point that should never move, etc.) so that we can give more relevant advices.
-
so I set his origin to his position
Don't forget that the origin is relative to your sprite. If your image is 50x50 and you want the origin in the center of it then set it to (25, 25), even if the sprite has e.g. position (100, 100).
Is that what you were doing wrong?
If not then you should provide a small example code so that it is clear what you are doing.
Yes, i guess thats exactly what I'm doing.
Thank you, knowing that origin is taken from the top left corner of sprite and not from the window I changed
my origin to the correct position and now works as intended.