【问题标题】:Images with transparent pixels packed with Texture Packer are black用 Texture Packer 打包透明像素的图像是黑色的
【发布时间】:2016-04-13 07:20:20
【问题描述】:

我尝试为动画创建带有透明图像的纹理图集。我最终得到的不是我的纹理,而是黑色方形图像,与我想要打包到纹理图集中的第一个纹理的大小相匹配。我使用了这个纹理打包器https://www.codeandweb.com/texturepacker,因为 libgdx 的 gui 由于某种原因无法打包它(它说发生了错误)。在透明图像之前,我将它用于普通的非透明图像,它工作正常。由于涉及透明度,我似乎得到了黑色图像。透明纹理有类似的问题吗?

代码:

mainCharAtlas= new TextureAtlas("Sh/mainChar.txt");
        mainCharRegions= new Array<TextureAtlas.AtlasRegion>(mainCharAtlas.getRegions());
        mainCharAnim= new Animation(1f/31f,mainCharRegions);

        mainChar= Decal.newDecal(mainCharRegions.first(),true);
        CameraGroupStrategy cameraGroupStrategy = new CameraGroupStrategy(camera);
        decalBatch=new DecalBatch(cameraGroupStrategy);
        mainChar.setPosition(0.14f, 0f - 1.83f, 0.64f);
        mainChar.setWidth(7f);

        mainChar.setHeight(7f);
        mainChar.setRotation(0, 90, 20.5F);

这是来自 txt 文件的示例:

mainCharacter.png
size: 4849, 4069
format: RGBA8888
filter: Linear,Linear
repeat: none
01
  rotate: false
  xy: 571, 1
  size: 568, 568
  orig: 906, 906
  offset: 168, 167
  index: -1
02
  rotate: true
  xy: 1141, 1
  size: 568, 572
  orig: 906, 906
  offset: 166, 161
  index: -1
03
  rotate: true
  xy: 2922, 1
  size: 577, 606
  orig: 906, 906
  offset: 161, 144
  index: -1

使用纹理打包器创建的mainCharacter.png 包含透明区域,这很好。

【问题讨论】:

    标签: libgdx texturepacker


    【解决方案1】:

    这里的问题很可能是纹理大小:

    size: 4849, 4069

    您必须保持在 4096 以下,即使这可能不适用于所有设备。我建议保持在 2048x2048 以下。

    这是一个硬件限制 - 您对此无能为力。

    【讨论】:

    • 你是绝对正确的。为了在移动平台上安全,我降低到 1024x1024,因为这是 libgdx 文档推荐的数字。
    猜你喜欢
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 2011-03-04
    • 2015-08-12
    • 2017-06-04
    • 2015-08-26
    • 2012-05-09
    相关资源
    最近更新 更多