Reputation: 323
So I've been looking through and experimenting some stuff but can't quite get how to remove pre-existing spriteBatch on screen.
so basically I have initiated
batcher.begin();
(blah blah blah)
AssetLoader.font.draw(batcher, "Hey guys", x, y);
something like this... now I wish to delete/remove/undraw this thing on screen... how do I do that without using if statement because.. if I start using If statements everything is going to get sooo messy.
Thanks so much!
Upvotes: 1
Views: 2721
Reputation: 25177
Its generally accepted practice in an OpenGL application to clear the screen every time and re-draw the entire screen.
So, to "erase" something, you just stop drawing it.
boolean wantToSeeThis = true;
...
void render() {
batcher.begin();
(blah blah blah)
if (wantToSeeThis) {
AssetLoader.font.draw(batcher, "Hey guys", x, y);
}
}
void hideIt() {
wantToSeeThis = false;
}
Upvotes: 5
Reputation: 8584
It is a bit unclear what you are asking. By default your screen gets cleared every frame with this line in the Render
method.
gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
Then obviously we need statements of when we want to draw things. If you code your whole program in a single class this obviously gets messy quick. But Java is OOP
which means you can add a classes with there own Draw
/Render
method and there own statements as to when they should be drawn. I suggest you start learning the basics of OOP
.
Upvotes: 3