Tile an image with SFML
c++, repeat, sfml, sprite, textures
Solution
After you load the image you need to call setReapeted:
texture.setRepeated(true);
And after that, when load texture in your sprite, set the texture rect to be to your size of screen:
sprite.setTexture(texture);
sprite.setTextureRect(sf::IntRect(0,0,800,600);
Problem
I have a background image and it's only 256 x 256 when my window is 800 x 600. I'm not sure how to get the image to repeat itself across the whole window. I currently load the image in with: ``` sf::Texture Bkg; if(!Bkg.loadFromFile("darkPurple.png")) { return -1; } sf::Sprite Sprite; Sprite.setTexture(Bkg); ``` and the draw it later with: ``` window.draw(Bkg); ``` I tried to use: ``` texture.setRepeated(true); ``` but that didn't seem to help. Thanks!