| 294 | } |
| 295 | |
| 296 | void Box2DTest::update(float dt) |
| 297 | { |
| 298 | // It is recommended that a fixed time step is used with Box2D for stability |
| 299 | // of the simulation, however, we are using a variable time step here. |
| 300 | // You need to make an informed choice, the following URL is useful |
| 301 | // http://gafferongames.com/game-physics/fix-your-timestep/ |
| 302 | |
| 303 | int velocityIterations = 8; |
| 304 | int positionIterations = 1; |
| 305 | |
| 306 | // Instruct the world to perform a single step of simulation. It is |
| 307 | // generally best to keep the time step and iterations fixed. |
| 308 | world->Step(dt, velocityIterations, positionIterations); |
| 309 | |
| 310 | // Debug draw |
| 311 | if (showDebugDraw) |
| 312 | { |
| 313 | drawBox2D->clear(); |
| 314 | world->DebugDraw(); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | void Box2DTest::onTouchesEnded(const std::vector<Touch*>& touches, Event* event) |
| 319 | { |