首先,感谢您阅读本文,欢迎任何帮助。 我的演员在舞台上正确渲染,但是使用Actions.moveTo,它会留下痕迹?我只是没有得到它。就像纹理在每个新帧上的新位置呈现一样。
以下是我班级的代码:
public class SlidingCap extends Actor {
private Texture capOver;
private float xPosition;
private float yPosition;
public SlidingCap(float x, float y) {
this.xPosition = x;
this.yPosition = y;
this.capOver = new Texture(Gdx.files.internal("images/cappingPlate.png"));
setBounds(x, y, 288, 180);
}
@Override
public void act(float delta) {
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.draw(capOver, getX(), getY(), 288, 180);
this.addAction(Actions.moveTo(xPosition+10, yPosition+10, 5f));
}
}
ScreenGame渲染方法:
@Override
public void render(float delta) {
gameStage.act(delta);
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
this.capMiniGame = new SlidingCap(100, 100);
this.gameStage.addActor(capMiniGame);
gameStage.draw();
}
答案 0 :(得分:1)
您使用此代码
每帧添加一个新的SlidingCapthis.capMiniGame = new SlidingCap(100, 100);
this.gameStage.addActor(capMiniGame);
尝试在Create或show方法中添加SlidingCap一次,而不是每帧