SFML community forums

Help => Graphics => Topic started by: dubesinhower on May 05, 2013, 04:41:59 am

Title: easiest way to repeat a texture to fill a rectangle
Post by: dubesinhower on May 05, 2013, 04:41:59 am
i'm trying to use a texture as a background, but when i use a sprite set with a texture that is set to repeat, it only shows the texture one time and it doesn't repeat. am i not using this function correctly?

i also tried applying the texture to a rectangle shape, but it just stretches the texture to fill the box one time.

any tips would be appreciated!
Title: Re: easiest way to repeat a texture to fill a rectangle
Post by: Laurent on May 05, 2013, 08:45:51 am
You must use a textureRect which is bigger than the texture size, and set the texture as repeated (texture.setRepeated(true)).

This is explained in the tutorial.
Title: Re: easiest way to repeat a texture to fill a rectangle
Post by: dubesinhower on May 05, 2013, 10:59:32 pm
the texture is set to repeat, and the area is huge compared to the texture. but it only stretches a single copy of the texture to fill the the rectangle.

edit: derp, didnt notice the need for textureRect as apposed to rectangleShape. ill check it out

edit: k figured it out. didn't know you had to set a sprite's textureRect to be the size of the rectangle i wanted to fill. thanks for the help!