2017-10-05 32 views
0

我还有一个问题LibGDX(-_-)。我有一个黑/白图像是这样的:LibGDX:为什么我的黑/白图片变得透明?

enter image description here

现在我尝试使用这个形象在我的播放屏幕我的背景图片:

类播放屏幕:

(...) 
Texture background; 
(...) 
background = new Texture("grid.jpg"); 
(...) 
gameHandler.getBatch().begin(); 
gameHandler.getBatch().draw(background,0,0,Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 
gameHandler.getBatch().end(); 
(...) 

类GameHandler :

(...) 
Gdx.gl.glClearColor(1, 1, 1, 1); 
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 
this.getScreen().render(Gdx.graphics.getDeltaTime()); 
(...) 

使用此代码我获得以下(错误的比例是因为视,但doesn't物质):

我怎样才能保持真实图像的颜色吗?

希望你能帮助我! 〜亨利

+1

以 “真” 为MIP映射实例化你的纹理,其minFilter设置为MipMapLinearLinear或MipMapLinearNearest。但它大多只会看起来灰暗,因为你正在缩小它以适应屏幕。如果您需要一个非常干净的网格并支持具有不同屏幕尺寸的设备,则需要在运行时通过适当设置UV来平铺图案。 – Tenfour04

+0

IM现在这样做的:d –

+0

我建议你用PNG贴敷LibGDX。 PNG图像使用逐像素精度的光栅,因此一个PNG图像加载程序与另一个PNG图像加载程序没有区别。另一方面,JPEG不包含原始的像素数据,更多的是解释。 – vedi0boy

回答

0

你的形象被打破。

试试这个:

enter image description here

知道我改变路径

1.png 
相关问题