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 in this recipe: variable timestep, fixed timestep, and fixed timestep with interpolation.
To understand the entire code, you should be familiar with Scene2D and the basis of this chapter. Go back and review if necessary. To simplify things, only...