SFML community forums
Help => Graphics => Topic started by: ravenheart on January 02, 2009, 07:58:57 pm
-
What exactly does GP return?
i thought it would return the position of the top left corner of a sprite.
now i have done following:
i reset the center of my sprite, and somehow my sprites position on screen changed too, what is the relationship between
Center and Position of a sprite?
and what does happen to the position if i rotate my sprite?
will the position still be the same or will it only be the same if rotationcenter and position are the same?
-
What exactly does GP return?
It returns the position of the origin (center) of the sprite. By default the center is the top-left corner, but you can change it.
i reset the center of my sprite, and somehow my sprites position on screen changed too, what is the relationship between Center and Position of a sprite?
Because Position is the position of Center, if you move the center within the sprite, its visual position will change too.
and what does happen to the position if i rotate my sprite?
As I said, Position is the position of the Center. And Center is the center of all transformations, including rotation. So it will never change regarding rotation and scaling.
-
ok so far so good
only one more thing what happens if i set my center OUTSIDE the sprite?
-
what happens if i set my center OUTSIDE the sprite?
Nothing more than when you set it inside ;)
-
well now i want to do something like that:
i have a window 400*400px
and i want two sprite to rotate round the center of the window
but i do want to know the distance between the two sprites too
is there any easy way to do it?
if i set the center of both in the middle of window, i cant work with GetPos anymore?
-
is it neccessary that i write my own fuctions?
-
Sorry, I don't understand why you're trying to achieve.
-
ok ill try to explain
i have two sprites that should go in circles
center of the rotation is the midle of the screen
i need the distance between the two sprites'
when i set the center of rotation = middle of screen, getposition will not return different values for both sprites
am i right?
-
ok ill try to explain
i have two sprites that should go in circles
center of the rotation is the midle of the screen
i need the distance between the two sprites'
when i set the center of rotation = middle of screen, getposition will not return different values for both sprites
am i right?
Yes, you are right. GetPosition will return the same value since you're not actually moving them. The reason is that you're misusing rotation to attempt to set the rendered position as well. If you want rotational movement about a center point, you should calculate the new position yourself and set that position.
-
Hello!
What really does the GetPosition return? "Cout" cant display it. I really dont get it. Witch type does it return?
-
The doc is your friend ;-)
http://www.sfml-dev.org/documentation/1.6/classsf_1_1Drawable.htm#9ad52594fd5e835cbd03b79098d70e0b
-
The doc is your friend ;-)
http://www.sfml-dev.org/documentation/1.6/classsf_1_1Drawable.htm#9ad52594fd5e835cbd03b79098d70e0b
Wow! I didn't now about that part of the website. Thank you.