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.
@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); ...
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.