SFML community forums

Help => General => Topic started by: kameleo327 on January 07, 2019, 11:14:53 pm

Title: Why getOrigin() doesnt return current position of object
Post 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 ?
Title: Re: Why getOrigin() doesnt return current position of object
Post by: NGM88 on January 08, 2019, 07:39:46 am
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
Title: Re: Why getOrigin() doesnt return current position of object
Post by: kameleo327 on January 09, 2019, 09:49:35 pm
No, i know what is setOrigin and getOrigin,
Why getOrigin after setOrigin and moving object doesnt return current pos of origin?
Title: Re: Why getOrigin() doesnt return current position of object
Post by: AlejandroCoria on January 09, 2019, 10:07:23 pm
Moving an object does not modify its origin (which is in local coordinates).
Title: Re: Why getOrigin() doesnt return current position of object
Post by: NGM88 on January 09, 2019, 10:12:43 pm
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).
Title: Re: Why getOrigin() doesnt return current position of object
Post by: Hapax on January 20, 2019, 11:12:47 pm
Just wanted to add that getPosition() actually returns the global location of the object's origin.