Hi everyone. I’m having an issue, and it’s really frustrating because of how simple it is . Drawing a Sprite isn’t working at all. I’m using LibGDX.
For example, with this code, when I draw the sprite, it is flashing really fast.
@Override
public void show() {
batch = new SpriteBatch();
texture = new Texture("ui/mainmenu.png");
mainMenu = new Sprite(texture);
mainMenu.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.begin();
mainMenu.draw(batch);
batch.end();
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
but with this code, my sprite doesn’t show up at all.
@Override
public void show() {
batch = new SpriteBatch();
texture = new Texture("ui/mainmenu.png");
mainMenu = new Sprite(texture);
mainMenu.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
mainMenu.draw(batch);
batch.end();
}
Thanks in advance