O'Reilly logo

Beginning Android Tablet Games Programming by Jeremy Kerfs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Putting Everything on the Screen

Now that you have lots of great features like your user interface controls and boats, you need to add them to the screen. To do so, the onDraw() function needs an adjustment. Listing 9-11 contains the entire code for the function.

Ensure that your onDraw function looks exactly like Listing 9-11 or the images will not be drawn to the screen.

Listing 9-11. onDraw()

@Override public void onDraw(Canvas canvas) {         canvas.drawColor(Color.BLUE);         ground.draw(canvas);         //the user controls         dock.draw(canvas);         marker.draw(canvas);         trash.draw(canvas);         cannonleftsmall.draw(canvas);         cannonrightsmall.draw(canvas);         cannondownsmall.draw(canvas);         cannonupsmall.draw(canvas); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required