在Libgdx中滑动背景

时间:2014-03-21 01:49:46

标签: android libgdx 2d-games

我是libgx的新手,我有一个基本的问题。我希望背景像图像一样重复,然后向下移动。我做了2张图片并且有效,但问题是非常慢。我用512x512px存储了图像。 我的代码很简单,但我不知道我做错了什么。

public void render() {
    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    offset -= 600 * Gdx.graphics.getDeltaTime();
        offset = offset % 512;
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(backgroundImage, 0, offset);
    batch.draw(backgroundImage, 0, offset + 512);
    batch.draw(bucketImage, 0, offset + 1024);
    batch.end();
}

任何建议将不胜感激 非常感谢!

1 个答案:

答案 0 :(得分:0)

我没有看到你的渲染方法会导致减速的任何原因,你确定那里发生了减速吗?我敢打赌它不是。缩小减速的根本原因,这可能是代码中的其他地方。

(我没有足够的声誉发表评论)