2016-01-08 89 views
1

我尝试使用透明图像为动画创建纹理图集。取而代之的是我的纹理,我最终得到了黑色的方形图像,将我想要打包的第一个纹理的大小与纹理图集进行匹配。我使用这个纹理打包器https://www.codeandweb.com/texturepacker,因为libgdx的gui由于某种原因无法打包它(它说错误已经发生)。在透明图像之前,我使用它作为正常的非透明图像,并且它工作正常。由于涉及透明度,我似乎正在变黑影像。有没有人有透明纹理类似的问题?包含Texture Packer的透明像素图像为黑色

代码:

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包含透明区域,这样是好的。

回答

2

这里的问题是最有可能的纹理尺寸:

size: 4849, 4069

您必须低于4096,甚至这可能不是在所有设备上工作。我建议保持在2048x2048以下。

这是一个硬件限制 - 你不能做太多的事情。

+0

你是绝对正确的。为了在移动平台上安全,我下载到了1024x1024,因为这是libgdx文档推荐的数字。 – brumbrum

0

a bug in libgdx TexturePacker(实际上是Java本身),可能会导致某些图像上的透明度被忽略。解决方法是将输入PNG保存为全色RGBA(而不是任何调色板或灰度模式)。