Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] C++, sf::shape.move doesnt change polygon position  (Read 1935 times)

0 Members and 1 Guest are viewing this topic.

Gazonga

  • Newbie
  • *
  • Posts: 3
    • View Profile
[SOLVED] C++, sf::shape.move doesnt change polygon position
« 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!
ThinkPad t41, OS: Ubuntu 10.04

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED] C++, sf::shape.move doesnt change polygon position
« Reply #1 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));
Laurent Gomila - SFML developer

Gazonga

  • Newbie
  • *
  • Posts: 3
    • View Profile
[SOLVED] C++, sf::shape.move doesnt change polygon position
« Reply #2 on: January 15, 2012, 01:03:11 pm »
Thanks! I'll try to mark this as solved if that is possible!
ThinkPad t41, OS: Ubuntu 10.04

 

anything