SFML community forums

Help => Graphics => Topic started by: Gazonga on January 15, 2012, 02:07:28 am

Title: [SOLVED] C++, sf::shape.move doesnt change polygon position
Post by: Gazonga on January 15, 2012, 02:07:28 am
Hi forum

I have a problem concerning the sf::Shape.move(x,y) function, it doesn't seem to change the positions of the various points in a polygon but only "the viewmode". It might be supposed to do only that, but when I use the sf::Shape.getPointPosition(0).x after have updated its position with sf::Shape.move(x,y) (every polygon does at least have the 0 element, and therefore the x, so I use that as a test) it doesn't return a different value, but always the values I initialized when i used sf::Shape.AddPoint(x,y...), even though I can see that the polygon has moved on the screen.

I want the sf::Shape.getPointPosition(i) to return the new position after the sf::shape.move have been executed, because Iam using it for collision detection.

Is there maybe some other workaround to this problem, or is there something essential I completely missed?

All help is very appreciated, thanks!
Title: [SOLVED] C++, sf::shape.move doesnt change polygon position
Post by: Laurent on January 15, 2012, 09:41:56 am
If you read the doc, you'll see that the returned points are in local coordinates, ie. the shape's transformations are not aplied to them. Use TransformToGlobal to apply them and convert the points to global coordinates.
Code: [Select]
sf::Vector2f p = shape.TransformToGlobal(shape.GetPointPosition(0));
Title: [SOLVED] C++, sf::shape.move doesnt change polygon position
Post by: Gazonga on January 15, 2012, 01:03:11 pm
Thanks! I'll try to mark this as solved if that is possible!