通过移动一个对象,LibGDX fps下降

时间:2016-05-05 12:41:28

标签: android libgdx frame-rate

我在libgdx中移动一个对象,但动画不顺畅。我在我的LG设备和genymotion上进行了测试,但是fps低于60.我不知道我做错了什么。请告诉我为什么fps正在下降。这是我的fps日志和代码

FPS LOG

public class MyGdxGame extends ApplicationAdapter {

int x;
SpriteBatch spriteBatch;
Texture texture;
Sprite sprite;
FPSLogger fpsLogger;

int screenWidth;

@Override
public void create() {

    spriteBatch = new SpriteBatch();
    texture = new Texture("badlogic.jpg");
    sprite = new Sprite(texture);
    fpsLogger = new FPSLogger();
    screenWidth = 1080;
}

@Override
public void render() {

    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    spriteBatch.begin();

    if (x > screenWidth)
        x = 0;
    x = x + 10;

    spriteBatch.draw(sprite, x, 0);
    spriteBatch.end();
    fpsLogger.log();
 }
}

0 个答案:

没有答案