How can I use my dragon as a Texture?
atlas = new TextureAtlas("myPack.atlas");
dragon = dragon.findRegion("dragon"); // returns TextureRegion
Creating Texture
from TextureRegion
is totally pointless.
Your TextureRegion
having rectangular points of your Texture so you can write particular texel to pixmap and then create Texture
from that Pixmap
.
TextureAtlas.TextureAtlasData.Region dragon = atlas.getRegion("dragon");
Pixmap pixmap = new Pixmap(dragon.width, dragon.height, Pixmap.Format.RGBA8888);
FileHandle pngFile = dragon.page.textureFile;
Pixmap completePix = new Pixmap(pngFile);
pixmap.drawPixmap(completePix, 0, 0, dragon.left, dragon.top, dragon.width, dragon.height);
Texture dragonTex=new Texture(pixmap);
atlas.findRegion("dragon");
? – Abhishek Aryan