SFML community forums
Help => Graphics => Topic started by: Nerolat on November 27, 2012, 06:55:28 pm
-
Hello, I keep getting 0 from GetPosition().x and GetPosition().y everytime I use it. No matter if it is a sprite, a shpae or anything.
x = Rect.GetPosition().x;
std::cout << x << std::endl; // Always prints 0;
Here is the line where I create that rectangle:
sf::Shape Rect = sf::Shape::Rectangle(0, 0, 20, 20, sf::Color::Red);
-
And? Until you call SetPosition, GetPosition will return the default position which is (0, 0).
-
Thanks for reply, Laurent, however even if I set it to
sf::Shape Rect = sf::Shape::Rectangle(100, 100, 20, 20, sf::Color::Red);
It still returns 0. Using SFML 1.6
EDIT:
Stupid of me. I thought first args of constructor are pos.
-
Stupid of me. I thought first args of constructor are pos.
Well RTFM (http://www.sfml-dev.org/documentation/1.6/)! it's so nice and easy understandable. ;)
Also I advise you to use SFML 2, because SFML 1.6 hasn't been touched over 2 years, has many bugs and lacks a lot of new and shiny features. :)
-
Stupid of me. I thought first args of constructor are pos.
Well RTFM (http://www.sfml-dev.org/documentation/1.6/)! it's so nice and easy understandable. ;)
Also I advise you to use SFML 2, because SFML 1.6 hasn't been touched over 2 years, has many bugs and lacks a lot of new and shiny features. :)
Thanks! You are my savior!
By the way, another question -
what shape should I use for lines? I thought there is a shape in SFML 2.0 especially made for lines.
-
None, use sf::vertices directly for that.
-
Two vertexes or a VertexArray with sf::lines as a primitive should suffice.
Check this for more details:
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Vertex.php (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Vertex.php)
http://www.sfml-dev.org/documentation/2.0/classsf_1_1VertexArray.php (http://www.sfml-dev.org/documentation/2.0/classsf_1_1VertexArray.php)