Deploying and Managing the Attack Boats

Listing 9-12 contains code for the entire GameView.java update() method that deals with the boats.. If you don’t understand a portion of it, type it in its entirety and run the game. You can see how it works based on the game’s behavior.

1. Make sure that your update() method includes all of the code here.  After the listing, you will find a explanation of it.

Listing 9-12. Setting Up the Boats in the update() Function

public void update(int adj_mov) {         for(int i = 0; i < boat_count; i++){                 if((int)boat[i].getX() > 950){                         boat[i].setMoveX(0);                         boat[i].setMoveY(3);                         boat[i].setBitmap(BitmapFactory.decodeResource(getResources(), ...

Get Beginning Android Tablet Games Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.