I'm using a TextureAtlas to organize all my images, and it works great when I need textures that scale to fit. However I want to create a background that is one region of the TextureAtlas repeated multiple times until a certain area is filled. I've tried setting the TextureWrap to Repeat like so:
public class Background extends Group {
SpriteActor bg;
public Background(int complexity) {
bg = new SpriteActor("background");
bg.getSprite().getTexture().setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
bg.setSize(Match.TRACK_WIDTH,Match.TRACK_HEIGHT); //These constants equal 12000
this.setSize(Match.TRACK_WIDTH,Match.TRACK_HEIGHT);
this.addActor(bg);
}}
where SpriteActor is just an Actor with a Sprite field:
public class SpriteActor extends Actor {
private Sprite sprite;
public SpriteActor(String assetName) {
super();
setSprite(new Sprite(Art.assets.findRegion(assetName)));
setWidth(sprite.getWidth());
setHeight(sprite.getHeight());
}
...
However the image is still stretched to fit the area (12000x12000 pixels), and not repeated. I'm guessing this is because the wrapping is set to the Texture, which basically contains ALL images in the TextureAtlas. What i'm looking for is a way to maybe set only the TextureRegion to repeat. Is there a way I can use both TextureAtlas AND have my image being repeated?