2017-04-08 76 views
0

首先,感谢您阅读本文,欢迎任何帮助。 我的演员在舞台上正确渲染,但与Actions.moveTo,它留下了一条线索?我只是不明白。这就像纹理在每个新帧上的新位置渲染一样。Libgdx - 对演员的行动

enter image description here

这是我为我的类代码:

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(); 
} 

回答

1

你添加新的SlidingCap每一帧,此代码

this.capMiniGame = new SlidingCap(100, 100);     
this.gameStage.addActor(capMiniGame); 

尝试在创建或显示方法而不是每个框架中添加SlidingCap一次

+0

我简化了需要这篇文章的代码,但是......我认为你是对的。让我试试这个。谢谢。 – Vini

+0

就是这样。不敢相信我没有看到它。非常感谢。 – Vini