Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How to fill region with repeated texture? Now I'm using next method:

spriteBatch.begin();

final int tWidth = texture.getWidth();
final int tHeight = texture.getHeight();

for (int i = 0; i < regionWidth / tWidth; i++) {
    for (int k = 0; k < regionHeight / tHeight; k++) {
        spriteBatch.draw(texture, i*tWidth, k);
    }
}

spriteBatch.end();

It's very obvious. Maybe is there any built in method?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

You want to set the texture's TextureWrap setting to Repeat. See the documentation for more information, and the texture method.

Specifically:

setWrap(Repeat, Repeat);
share|improve this answer
    
Thank you very much :) –  Fox in socks Aug 20 '12 at 17:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.