【发布时间】:2021-05-14 16:04:33
【问题描述】:
所以这是我的问题。我有一个 800x800 libgdx 游戏,我使用 gimp 创建了一个 800x800 .png。我添加它并绘制它,但现在图像似乎比预期的要大得多。例如,如果我有一个海洋 .png,则呈现的只是深蓝色屏幕。似乎它正在接受我的形象,但我做错了其他事情。任何帮助都是极好的。代码如下。玩家和敌人都渲染得很好并且在蓝色之上。
private Texture img;
private TextureRegion textureRegion;
float drawingWidth,drawingHeight;
//Constructor
public GameScreen(Game game) {
this.game = game;
img = new Texture("tester2.png");
img.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.ClampToEdge);
int width=Gdx.graphics.getWidth();
textureRegion=new TextureRegion(img,0,0,width,img.getHeight());
drawingWidth=width;
drawingHeight=Gdx.graphics.getHeight();
Gdx.app.log(ID, "GameScreen is loaded! " + drawingWidth + " " + drawingHeight);
}
@Override
public void render(float deltaTime) {
//buffer screen
Gdx.gl20.glClearColor((11f / 255.0f), (11f / 255.0f), (11f / 255.0f), 1);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
sb.begin();
sb.setProjectionMatrix(camera.combined);
update(deltaTime);
sb.draw(textureRegion,0,0,drawingWidth,drawingHeight);
sb.draw(img, 0, 0);
player.render(sb);
enemy.render(sb);
sb.end();
}
【问题讨论】: