# Game Update in Libgdx

In libgdx, the game loop is the render() method. But why is that, and is there a way where I can make an update() method that is called 60 times a second? As in the update() method, I would add the game logic, and leave the rendering to the render method. Basically, separate methods, and the update() method called 60 times per second using Libgdx with java.

• I think you should wait a bit longer to accept an answer. This question has only been viewed 9 times (at the time of be writing this). It is usually best to wait a bit to see if more answers come in. – Lysol Mar 14 '14 at 0:43

There is no specific game loop in libGDX because it is event-driven. And still, you can see the render method as the main loop.

You've got it right - usually, this is where you update the game logic before you do the rendering.

What you can do is to create a class responsible for the logic and a class responsible for the rendering. Then in your render method you write

@Override
public void render(float deltaTime) {
if(!paused)
LogicClass.update(deltaTime);
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
RenderClass.render(deltaTime);
}


You can read more about the life cycle in libGDX in its wiki on github: https://github.com/libgdx/libgdx/wiki/The-life-cycle.

• Hmmm... This might work :D All I need to do is find out how to make it update at 60 times per second. – user43353 Mar 13 '14 at 23:59
• You can limit the FPS by changing the configuration. This is a similar question to yours and you will find the answer useful: link – Mihail Ivanov Mar 14 '14 at 0:09