Drawing the explosion on the screen

We still have to draw our explosion effect on the screen, and yes, you are right! We will do so in our draw() method. We also have to make sure that we draw our explosion only once, that is, at the start of the game, and so we will use our started variable to keep track of it:

if(started) {    explosionEffect.draw(canvas);}

We're all set with our draw logic as well. We're done with the entire logic for our explosion effect, and now your entire code for the GameView.java file should look somewhat like the following; all the changes done in this chapter are marked in bold:

//Package name and import statements remain same as previous chapterpublic class GameView extends SurfaceView implements SurfaceHolder.Callback ...

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.