Chapter 7. Detecting Collisions and Reacting to Events

In this chapter, we are going to add a physics-based collision detector to our game and create events based on the detected collisions. We are going to learn how to trigger events from different phases of a collision and for specific types of colliding bodies. We will also learn how to handle these collision events and many other events such as "game over".

Finally, we are going to learn how to play sound effects that we prepared earlier in the game during the events to improve their overall feel.

Collisions

Collisions are an integral part of the physics engine. Algorithms used in Box2D are nicely optimized and we will take advantage of it. However, we will be adding and removing physics bodies ...

Get Learning AndEngine 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.