I want to use setFilter(TextureFilter.Linear, TextureFilter.Linear);
on my image, taken from textureAtlas. when I use
TextureRegion texReg = textureAtl.findRegion("myImage");
Sprite = new Sprite(texReg);
it's works fine, but if i try
TextureRegion texReg = textureAtl.findRegion("myImage");
Texture myTexture = new Texture(texReg.getTexture());
myTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Sprite mySprite = new Sprite(myTexture);
mySprite contains all textureAtlas images. How to set to Texture single image from textureAtlas?
Your last line should be:
Sprite mySprite = new Sprite(texReg);
Texture can represent a single image or multiple images (texture atlas). When there are multiple images, each is location in its texture region. You can only apply filtering to the entire texture and therefore all the images in it. If you want to apply it only to a single image, it needs to be in a separate texture.
So here is what you were doing with your code:
// get the image for your game (or whatever) object
TextureRegion texReg = textureAtl.findRegion("myImage");
// get the texture that is the 'container' of the image you want
Texture myTexture = new Texture(texReg.getTexture());
// apply filtering to the entire texture and all the images
myTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
// set the entire texture as the image for your sprite (instead of only a single region)
Sprite mySprite = new Sprite(myTexture);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With