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() {
}
}
我正在获取上述代码的输出
但是我需要移除后面的星星,对于每个星星,我该怎么做?
答案 0 :(得分:5)
您需要在每个帧之前清除屏幕,如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();
}
答案 1 :(得分:1)
首先在功能render
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
.....
}