SFML community forums

Help => Graphics => Topic started by: Gauzr on June 12, 2015, 06:48:32 pm

Title: Get position of entity local to a window/view
Post by: Gauzr on June 12, 2015, 06:48:32 pm
Hi, I would like to get simply the y coord of a shape, but when I try do this it only gets the y distance from it's origin. I don't want this. I want to get the y coord of the whole 600x600 window (with 0, 0 at top left) but using setOrigin. Sorry if my English was a bit bad.


shape.setOrigin(-50, -400);
...


int shapepos_y = shape.getPosition().y ; // when the shape moves up 50 for example, it only returns -50, but I need it -350

std::cout<<"shapepos_y =" << shapepos_y;
 
Title: Re: Get position of entity local to a window/view
Post by: eXpl0it3r on June 12, 2015, 07:39:51 pm
getPosition() provides the position of the origin.

I suggest you read the official tutorials (again), because setting the origin to negative value is very rarely what you actually want to do. To set he shape's position use setPosition().
Title: Re: Get position of entity local to a window/view
Post by: Hapax on June 12, 2015, 07:52:30 pm
I am curious as to what you intended to achieve with this:
shape.setOrigin(-50, -400);
Title: Re: Get position of entity local to a window/view
Post by: Gauzr on June 12, 2015, 08:33:09 pm
Ah, now I think I could of just setPosition(positive cords) done instead... This was the solution to this, thanks for the info.