2
\$\begingroup\$

I'm creating a game with libgdx. For testing physics I use a Box2DDebugRenderer, which is not fast. When I want to release my full game, what should I use as a renderer?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

I haven't used Box2D itself (only ports and things based off of it), but the name "Box2DDebugRenderer" suggests that you should not render anything that should be in the final product whatsoever based on it.

Use it to draw collision bounds and collision contact points. This is very useful visual information to see while you're developing your game. The game itself should have its own renderer. Isn't that part of what LibGDX is supposed to provide?

\$\endgroup\$
2
  • \$\begingroup\$ sorry but what do you mean with "Use it to draw collision bounds and collision contact points" ? \$\endgroup\$
    – Ion Farima
    Feb 20, 2013 at 13:04
  • \$\begingroup\$ @IonFarima Each object in your Box2D scene has a Body and Collision Shape associated with it that is used to determine its interactions and collisions with other bodies. The shape is not necessarily the same shape as the sprite/other visuals you associate the physics body with. So you turn on this debug renderer so you can see what the actual internal shapes Box2D is using to calculate collisions look like. Contact points are the points along bounding boxes where two bounding boxes have collided. \$\endgroup\$ Feb 20, 2013 at 15:15
0
\$\begingroup\$

It depends on what you want to render :) Box2d needs step updating to simulate physics only.

world.step(boxStep, BOX_VELOCITY_ITERATIONS, BOX_POSITION_ITERATIONS);

if (DEBUG_PHYSICS) {
    debugRenderer.render(world, camera.combined.scale(100f * PHYSICS_SCALE, 100f * PHYSICS_SCALE, 0));
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .