使用 Texture Packer 打包的透明像素图像是黑色的

Images with transparent pixels packed with Texture Packer are black

我尝试用透明图像创建纹理图集用于动画。我最终得到的不是我的纹理,而是黑色方形图像,与我想要打包到纹理图集中的第一个纹理的大小相匹配。我使用这个纹理打包器 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 使用纹理打包器创建的包含透明区域,这样很好。

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

size: 4849, 4069

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

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