0
votes

I'm working on a top down RPG game using LibGDX, and am creating an Ortho.. camera for my game. However in doing so, only my tile textures render now. This is how the render code looks:

Camera initialized as new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

(note that the camera. calls are actually in the world.update method, I just figured I would minimize the amount of code needed on here)

Updating/Rendering:

camera.position.set(getPlayer().getPosition().x, getPlayer().getPosition().y, 0);
camera.update();
batch.setProjectionMatrix(world.getCamera().combined);
batch.begin();
world.render(batch);
batch.end();

the world's render method ends up calling this:

public void render(SpriteBatch batch, float x, float y, float w, float h) {
    batch.draw(region, x, y, w, h);
}

Where region is a TextureRegion

Without the camera, it all works just fine, so I am very confused as to why textures only render in order now (my tile textures are rendered below entities) Does anyone have any idea why this might be? In case you want to see more code, I also have this on my github: CLICK HERE

2
You have a couple methods called on camera, but then you set the batch's projection matrix with world.getCamera. Are these the same camera? - Tenfour04
@Tenfour04 Yes, the camera. calls are copied from the world.update I just figured I would minimize the code needed to go on here - BossLetsPlays

2 Answers

2
votes

I hadn't realized this later, but I was commenting out a lot of rendering lines, line by line to see if I could find what was wrong, it turns out that my debugging tool I made (which renders collision bounds using a ShapeRenderer) was messing it up because apparently, a ShapeRenderer cannot be used between a batch.begin and a batch.end

I figured this out with the help of this badlogicgames forum post

0
votes

Can't get much out of the code but are you using this at the root of the render structure?

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);