Chapter 3. Interacting with Bodies

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 ...

Get Box2D for Flash Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.