【问题标题】:libGDX: convert TextureRegion to TexturelibGDX:将 TextureRegion 转换为 Texture
【发布时间】:2017-07-11 20:59:18
【问题描述】:

如何将我的龙用作纹理?

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

【问题讨论】:

  • atlas.findRegion("dragon"); ?

标签: libgdx textures texturepacker


【解决方案1】:

TextureRegion 创建Texture 完全没有意义。


您的TextureRegion 具有纹理的矩形点,因此您可以将特定的纹素写入像素图,然后从该Pixmap 创建Texture

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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    • 2016-08-11
    相关资源
    最近更新 更多