2017-07-11 8 views
0

私のドラゴンをテクスチャとして使用するにはどうすればよいですか? TextureRegionからTextureを作成するlibGDX:TextureRegionをテクスチャに変換する

atlas = new TextureAtlas("myPack.atlas"); 
dragon = dragon.findRegion("dragon"); // returns TextureRegion 
+0

'atlas.findRegion(" dragon ");'? – Aryan

答えて

0

は全く無意味です。


あなたはピックスマップとそのPixmapからTextureを作成するために、特定のテクセルを書き込むことができますので、あなたのTextureRegionは、あなたのテクスチャの長方形の点を有します。

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); 
関連する問題