I have a sf::RectangleShape in my code which is defined like this :

sf::RectangleShape shape_1;

And it's values are set like this :

shape_1.setPosition(10, 10);

But when I render it like this :


It wont display in my window.

My rendering part of the code looks like this :




Not sure what I'm doing wrong. Have been going on for days thinking it was a position problem with a body but since this won't render either it can't be. :P

  • \$\begingroup\$ You'll have to show more code. Where do you set the shape's dimensions? Do you set them at all? The code you're showing looks fine as far as I can tell. \$\endgroup\$ – Mario Dec 20 '15 at 21:25

You have to set the size of the rectangle with setSize.

shape_1.setSize(sf::Vector2f(100.f, 100.f));
| improve this answer | |
  • \$\begingroup\$ Not sure why I didn't think of that.... Thank you ^-^ \$\endgroup\$ – BiiX Dec 20 '15 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.