LibGDX: Why my black/white picture gets transparent?

我的未来我决定 提交于 2019-12-24 20:45:36

问题


I have another LibGDX Problem (-_-). I have an black/white image like this:

Now I try to use this image as my background image in my PlayScreen:

Class PlayScreen:

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

class GameHandler:

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

Using this code I get following(wrong scale is because viewport, but that doesn´t matter):

How can I keep the colors of the real image?

Hope you can help me! ~Henri


回答1:


Your image is broken.

Try this:

Know that i changed path to

1.png


来源:https://stackoverflow.com/questions/46588036/libgdx-why-my-black-white-picture-gets-transparent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!