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.

  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – 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

public void render(float deltaTime) {
    Gdx.gl.glClearColor(0, 0, 0, 0);

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.