正如泰图斯所说,不要多次加载纹理, 曾经!不管怎样,你的包装器走在正确的轨道上:
texture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
现在您可以仅使用带有源位置的绘制方法。源位置是您选择在纹理上绘制的区域。
batch.draw(texture, x, y, srcX, srcY, srcWidth, srcHeight)
要从右向左滚动纹理,您所要做的就是逐渐增加 srcX。因此,创建一个在 update/render 方法中递增的 int 。
int sourceX = 0;
//render() method
//Increment the variable where to draw from on the image.
sourceX += 10;
//Simply draw it using that variable in the srcX.
batch.draw(YourTexture, 0, 0, sourceX, 0, screenWidth, screenHeight);
因为您正在包裹纹理,所以它将无限期地包裹/循环和滚动。如果游戏运行很长时间,sourceX int 可能会出现问题,因为 int 只能保存 2147483647。这需要一段时间,但您可以通过每次数字超过总图像宽度时减去图像宽度来修复它。