我正在使用 LibGDX 开发一个自上而下的 RPG 游戏,并且正在为我的游戏创建一个 Ortho.. 相机。然而,这样做,现在只有我的瓷砖纹理渲染。这是渲染代码的样子:
相机初始化为new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
(请注意,camera.
调用实际上是在world.update
方法中,我只是想我会尽量减少此处所需的代码量)
更新/渲染:
camera.position.set(getPlayer().getPosition().x, getPlayer().getPosition().y, 0);
camera.update();
batch.setProjectionMatrix(world.getCamera().combined);
batch.begin();
world.render(batch);
batch.end();
世界的渲染方法最终调用这个:
public void render(SpriteBatch batch, float x, float y, float w, float h) {
batch.draw(region, x, y, w, h);
}
region
一个在哪里TextureRegion
没有相机,一切都很好,所以我很困惑为什么纹理现在只能按顺序渲染(我的平铺纹理在实体下方渲染)有人知道为什么会这样吗?如果您想查看更多代码,我的 github 上也有这个:点击这里