如何将龙用作纹理?
atlas = new TextureAtlas("myPack.atlas");
dragon = dragon.findRegion("dragon"); // returns TextureRegion
答案 0 :(得分:0)
从Texture
创建TextureRegion
毫无意义。
您的TextureRegion
具有纹理的矩形点,因此您可以将特定纹理像素写入像素图,然后从Texture
创建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);