O'Reilly logo

Libgdx Cross-platform Game Development Cookbook by Alberto Cejas Sánchez, David Saltares Márquez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The fixed timestep approach

The Box2D world's inner simulation process advances every frame as the programmer orders in the step function. The specified amount of time will determine the speed of this simulation, having a direct impact on the game experience.

Delimiting a certain number of milliseconds might seem simple but the truth is that there are a good variety of ways to perform this.

The FIX YOUR TIMESTEP! article is the father of this recipe, so do not hesitate to read it at http://gafferongames.com/game-physics/fix-your-timestep/.

Getting ready

Run the code within Box2DFixedTimeStepSample.java, so you will see a scene where boxes fall from the sky and there are three buttons at the bottom. Each of them enable one of the three approaches covered ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required