0
\$\begingroup\$

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.setFillColor(sf::Color::White);
shape_1.setPosition(10, 10);

But when I render it like this :

    window.draw(shape_1);

It wont display in my window.


My rendering part of the code looks like this :

    window.clear();

    window.draw(*box.getSfShape());
    window.draw(*box_static.getSfShape());
    window.draw(shape_1);

    window.display();

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

\$\endgroup\$
1
  • \$\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
    Commented Dec 20, 2015 at 21:25

1 Answer 1

3
\$\begingroup\$

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .