SFML community forums
Help => Graphics => Topic started by: dotty on January 22, 2012, 07:34:31 pm
-
As the title suggests, I'm using FloatRects for some collision detection. Is it possible to draw these to the screen so I can see their positions? I know I could simple copy the attributes of said FlaotRect then create a Shape, but I'm wondering if it's possible without the need of using Shape.
Thanks!
-
If you are using SFML 2 you can use sf::Vertex class. If not, I think that sf::Shape is the unique option (unless you use openGl directly).
-
sf::RectangleShape
?
-
sf::RectangleShape
?
Omg, I have not noticed about that class until now :lol:
Sorry, anyway it's a sf::Shape based class.
-
but RectangleShape doesn't have the methods like Intersect and Contains though.
-
but RectangleShape doesn't have the methods like Intersect and Contains though.
Just use your FloatRect for collision detection and create a RectangleShape from it when drawing:
sf::RectangleShape shape(sf::Vector2f(rect.Width, rect.Height));
shape.SetPosition(rect.Left, rect.Top);
window.Draw(shape);
-
I guess that's the only way to do it. Ok, thanks.