Drawing our objects on the screen

Once we are done, we simply draw our object on the screen in our if a block of ourdraw() method:

for(Rock r : rocks) {    r.draw(canvas);}

And that takes care of all the functionality needed to detect a collision.

Now that we are done with our collision logic, let's make a few tweaks to our player character. We have some unused variables there so let's get rid of them and customize it a little further. Prior to this, they were needed to get an understanding how things work. But now they are pretty useless to us, so there's no need for them to be lying around. Open up your PlayerCharacter.java and make the following changes to your code:

package nikhil.nikmlnkr.game;import android.graphics.Bitmap;import 

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.