I would like to set the texture of a RectangleShape, but I don't understand how you do it like in the documentation. Can someone tell me how to do it please? I created my texture and rectangleshape but I don't know how you actually set it. My code doesn't seem to work.
sf::Texture rectex;
rectex.loadFromFile("resources/texture");
rectangle.setTexture(rectex);
Ah, unlike sf::Sprite's setTexture() which takes a reference to an sf::Texture, sf::RectangleShape's setTexture() takes a pointer to an sf::Texture.
Try:
rectangle.setTexture(&rextex);
Does that fix your problem?
It's actually sf::Shape that takes the pointer and sf::RectangleShape is derived from that.
Not sure why Shape takes a pointer while Sprite takes a reference. For consistency, they should be the same (preferably reference) if possible.