Spawning our explosion

We need our explosion to spawn after our player has collided with our rocks. Once our player collides with a rock, the game is over. So, all of that is handled in our update() function wherein we have already created an else block for our newGame() function to be called. Let's utilize that and write our logic to spawn an explosion. Our objective here is as follows:

  • Spawn the explosion effect
  • Start a counter to wait for a certain time after a collision
  • Reset the game after a certain time

Note here that the dimensions of our image are 500 x 500, so we will be splitting our image into equal parts for each of our frames, thereby giving us 25 parts, which are 100 x 100 in dimension. We will pass each into our constructor ...

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.