Every Box2D based game has its own way to interact with bodies. Totem Destroyer and Red Remover allow the player to destroy bodies by clicking them with the mouse, while Angry Birds makes bodies (birds) fly by dragging them. You already know how to create primitive and complex bodies; it's time to see how Box2D allows us to interact with bodies in its world.
In this chapter you will learn various ways to interact with and get information from Box2D bodies, including:
Selecting bodies with the mouse
Destroying bodies
Setting custom properties to bodies
Looping through all bodies in the world
Getting body information
By the end of the chapter, you will have a completely playable Totem Destroyer level.
The simplest and most intuitive way by which we can interact with Box2D bodies is destroying them with a mouse click.