简体   繁体   中英

Can I tile a texture on a RectangleShape?

I have a rectangleshape that can change size in a program of mine (I won't copy it here as it is too large), and I have assigned a 64x64 pixel texture to it. The shape itself is much larger than the texture, but the texture just gets spread over the whole shape. Is there a way to change it so that the texture remains 64x64, but tiles across the rectangleshape?

Figured out how to do it, I just had to use the line

tex.setRepeated(true);

and the line

rect.setTextureRect(sf::IntRect(0, 0, xRect, yRect));

with xRect and yRect being the dimensions of the rectangleobject, tex bing the texture name and and rect being the rectangle object that the texture has been assigned to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM