Game Development Reference
In-Depth Information
Running the simulation
As I said before, you use the Step method to run the simulation, usually inside your main
loop, though not necessarily:
world->Step(dt, 8, 1);
You need to pass it the time step, here represented by the delta time in the main loop. Then
pass the number of velocity iterations and position iterations in the step. This basically
means how many times velocity and position will be processed inside a step.
In the previous example, I'm using the default values from the Box2D template in
Cocos2d-x. Usually, a fixed time step is better than the delta, and a higher value for posi-
tion iteration may be necessary if things move really fast in your game. But always remem-
ber to play with these values, aiming at finding the lowest possible ones.
Search WWH ::




Custom Search