The difference is very simple. The Box2dDebugRenderer
is extremely simple to use. It basically requires just a single line of code (the one you already wrote in your question), and it will render simple shapes to visualize your Box2D World
. It will render coloured squares, circles, lines and points for Fixture
s, Joint
s or Contact
s.
The second approach you posted is completely selfmade. You can draw whatever you want for the Body
. You can draw a simple shape yourself, or a sprite, or maybe an animation or even a 3D model. Maybe even nothing.
That's the "problem" with Box2D. The World
you create is purely a physics world and Box2D does not know how to render anything, that's what you have to do yourself. A squared Fixture
attached to a Body
could be a wall, it could be a box or a door.
This other question on SO has a few pictures which show the difference when both rendering methods are used. (Unfortunately they are rendered on different places, which is what this quesion was about).