How we can remove the back texture in libGDX?
Question
private Texture druidTexture;
private SpriteBatch batch;
Sprite sprite;
@Override
public void create() {
druidTexture = new Texture(Gdx.files.internal("star-large.gif"));
sprite = new Sprite(druidTexture);
batch = new SpriteBatch();
}
@Override
public void dispose() {
}
@Override
public void pause() {
}
@Override
public void render() {
batch.begin();
sprite.rotate(45);
float x=sprite.getX();
float y=sprite.getY();
float newx=x+1;
System.out.println(newx);
float newy=y+1;
sprite.setX(newx);
sprite.draw(batch);
batch.end();
}
@Override
public void resize(int arg0, int arg1) {
}
@Override
public void resume() {
}
}
i am getting output for the above code as this
but i need to remove the star at back,for each star,how can i do that??
Solution
You need to clear the screen before each frame as described here:
public void render () {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // This cryptic line clears the screen.
batch.begin();
// Drawing goes here!
batch.end();
}
OTHER TIPS
Clear the screen firstly in function render
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
.....
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow