@Override public void create() { batch = new SpriteBatch(); img = new Texture("badlogic.jpg"); } @Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (x < 0 || x > 400) { speed = -speed; } x += speed * Gdx.graphics.getDeltaTime() * 60; Gdx.app.log("delta",Gdx.graphics.getDeltaTime()+""); batch.begin(); batch.draw(img, x, 0); batch.end(); }
I had a problem and created a new project. The problem libgdx is trying to save 60FPS, and the avarage devaluation is ~ 16 ms. Some renderers take + 20 ms, then the next render takes 12 ms (render1 + render2 = 32ms) to reach 60FPS. It makes a laggy game. As you can see, I have nothing in the project, and this is the same in desktoplaunch. How did you decide that?
Note. I also tried reqeustRendering. But this is the same if the render takes longer than the average. I also tried to wait some time for rendering if it is less than 16 ms. It didn’t help either. This has no problem with the GC. I am using Libgdx 1.6.4.
source share