Structuring Sub' Hunter with methods
As we add the method definitions to the code it shouldn't come as much surprise where each of the methods will go. The draw
method will go after the comment about … do all the drawing…
and so on.
Add the newGame
method definition after the appropriate comment as shown next.
/* This code will execute when a new game needs to be started. It will happen when the app is first started and after the player wins a game. */ void newGame(){ }
Add the draw
method definition after the appropriate comment as highlighted.
/* Here we will do all the drawing. The grid lines, the HUD, the touch indicator and the "BOOM" when a sub' is hit */ void draw() { }
Add the onTouchEvent
definition after this comment.
/* This part of the ...
Get Learning Java by Building Android Games - Second Edition 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.