Hi,
I want to display a background using a tiled pattern.
I know this can be achieve by using a sprite with a repeated texture, but I want to avoid using one image per pattern, because I'd like to group them in a single sprite sheet (I intend to deal with many small patterns so a single image would be much more efficient and convenient).
For example, this is a 64x64 spritesheet with 4 32x32 patterns.
Let's say I want to draw a 640x480 background with the top-left pattern.
I tried using a RectangleShape and a repeated texture:
sf::Texture patterns;
patterns.loadFromFile("patterns.png");
patterns.setRepeated(true);
sf::RectangleShape background;
background.setTexture(&patterns);
background.setTextureRect(sf::IntRect(0, 0, 32, 32));
background.setSize(sf::Vector2f(640, 480));
But I just ended with a streched/scaled background:
Any advices?