Adding Boundaries and Using Sprites to Create Explosions

In our preceding chapter, we covered the part where we successfully detected collisions. Now that we have understood how to deal with collisions, we can play around with our knowledge and add some cool stuff to our game. This chapter will be pretty concise, and if you have understood the concept of collision detection properly, then this will be a breeze for you. Here's what we will do in this chapter:

  • Add a ground for our player as a boundary
  • Detect a collision between our player and rocks
  • Spawn an explosion sprite on the point where a collision takes place

Observe that from the preceding tasks, we have already accomplished our second task, so we have to focus on the first and third ...

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.