如何在Libgdx中自动循环后台参与者对象?

如何在Libgdx中自动循环后台参与者对象?,libgdx,scroll,2d,actor,stage,Libgdx,Scroll,2d,Actor,Stage,我想制作一个2D侧滚游戏,其中游戏世界/游戏舞台向左移动,即背景像Flappy Bird一样向左移动。你知道我如何能够自动循环一个背景演员对象,它的宽度和高度与舞台的正交摄影机相同吗 其实很简单。您所需要做的就是在Actor实例上使用moveByx,y方法 float xMovingDelta = 10; float yMovingDelta = 10; actor.moveBy(xMovingDelta, yMovingDelta); // Make sure you call the mov

我想制作一个2D侧滚游戏,其中游戏世界/游戏舞台向左移动,即背景像Flappy Bird一样向左移动。你知道我如何能够自动循环一个背景演员对象,它的宽度和高度与舞台的正交摄影机相同吗

其实很简单。您所需要做的就是在Actor实例上使用moveByx,y方法

float xMovingDelta = 10;
float yMovingDelta = 10;
actor.moveBy(xMovingDelta, yMovingDelta);
// Make sure you call the moveBy() method in a loop eg. the render() method.
下面是我过去游戏中的一个例子:它使用一个表实例,但它们都有moveBy方法

private void mMenuToDiffMenuAnimation() { // I call this method from the render() meth.
    if(difficultyTable.getX() > (540 - 64)){
        menuTable.moveBy(-30, 0);
        difficultyTable.moveBy(-30, 0);
    }else {
        fromMMToDiffMenu = false; 
       /* When the table's xPos is greater than 540 -64 stop the animation.*/
    }

}

此解决方案不会产生连续循环,但只会移动once@Mr.Developer-这就是为什么我添加了一条注释,指出moveBy方法需要在循环中调用。