It's been a while since I used LibGdx, so I feel like I'm just missing something obvious.
My render method in MyGdxGame looks like this, calling for the stage to draw itself (along with its actors), and then I try to draw a set of textures for debugging purposes.
@Override
public void render()
{
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
StageManager.getCurrentStage().act();
spriteBatch.begin();
StageManager.getCurrentStage().draw();
for(int i = 0; i < 100; i++)
{
spriteBatch.draw(TextureManager.getPlayerTexture(), 50*i, 50*i);
}
}
The stage is drawn along with its one actor, but the other textures are not being drawn.
What I've tried: setting batch projection matrix off the stage camera(after calling update
), making sure the texture coordinates should be visible.
The actor gets its texture from the same TextureManager.getPlayerTexture
so I don't think its a texture issue.
What else should I check for to get the textures drawn as well?
spriteBatch.begin()
followed bystage.draw()
will throw a RuntimeException. – Tenfour04stage.draw()
internally callsbegin
andend
on the batch. To draw additional stuff, you need to wrap those draw calls inbegin()
andend()
. – Tenfour04create
method? Maybe you have two sprite batches in use. Stage instantiates its own if one is not passed to its constructor. – Tenfour04