SFML community forums
Help => General => Topic started by: kameleo327 on January 07, 2019, 11:14:53 pm
-
Like in topic,
I used getOrigin() to center begin and end of line in rect when it is inside rectangle area to .
I want to get origin of rectangle with getOrigin(), but why it doesnt return current value of origin.
Why getPosition do it ?
-
You seem to be confusing get functions and set functions. You can consult the official tutorials for examples:
https://www.sfml-dev.org/tutorials/2.5/graphics-transform.php
-
No, i know what is setOrigin and getOrigin,
Why getOrigin after setOrigin and moving object doesnt return current pos of origin?
-
Moving an object does not modify its origin (which is in local coordinates).
-
No, i know what is setOrigin and getOrigin,
Why getOrigin after setOrigin and moving object doesnt return current pos of origin?
Because getOrigin returns origin. If you have a (50, 50) sized rectangle and setOrigin(25, 25) to place the origin at the center of the rectangle, and then position the rectangle at (1000, 1000) world coordinates, getOrigin would return (25, 25) and getPosition would return (1000,1000). What you are doing by setting origin is changing which pixel of the rectangle will be "sitting on" (1000, 1000).
-
Just wanted to add that getPosition() actually returns the global location of the object's origin.