Detecting collisions in our game

Since we are dealing with a game here, we will be dealing with the theory with a practical application. So, let's a take up a task of studying collision techniques with an example of an approaching rock toward the player. Our game is a side scrolling game and therefore there will be multiple obstacles and collectibles heading our way. Through the simple Bounding Box Collision technique, we can detect collisions between our player and other objects and execute corresponding functions.

After we are done creating our incoming rocks, we will also create incoming coins so that the player can score points as well. However, before we proceed with this, we have to come up with a way for our player to avoid these obstacles ...

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.