I am trying to get the Texture from Sprite or Atlas Region created by Texture Atlas.
atlas=new TextureAtlas(Gdx.files.internal("Test.pack"));
region=atlas.findRegion("green");
or
Sprite s = atlas.createSprite("red");
texture = s.getTexture();
I have given the name of image in findRegion and createSprite method, it always picks the other image object. I want to get the texture of the image so that part of that texture can be rendered.
Here is the Packer image: http://i61.tinypic.com/neupo2.png
Even if i try to get green region or red, it always returns blue. Any help would be appreciated.
When you do "textureAtlas.findRegion("objectTexture").getTexture();" (from James Skemp's answer) you're getting the whole texture from the atlas, not just from the region "objectTexture".
Don't bother creating Texture to create the Sprite, you can use the TextureRegion to create the Sprite. Something like this:
atlas=new TextureAtlas(Gdx.files.internal("Test.pack"));
regionGreen=atlas.findRegion("green");
Sprite s = new Sprite(regionGreen);
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