O'Reilly logo

Learning AndEngine by Martin Varga

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required