Linking up our methods
So far, we know that we can define methods with code like this:
void draw(){ // Handle all the drawing here }
And we can call/execute methods with code like this:
draw();
We have also alluded to, as well as mentioned in our comments that the onCreate
method (provided automatically by Android) will handle the One-time Setup part of the flowchart.
The reason for this is that all Android games (and the vast majority of other Android apps) must have an Activity
class as the starting point. Activity
is what interacts with the operating system. Without one the operating system cannot run our code. The way that the operating system interacts with and executes our code is through the methods of the Activity
class. There are many methods in the Activity
class but the one we care about right now is onCreate
.
The onCreate
method is called by Android itself when the player taps our game's icon on their screen.
Note
Actually, there are a number of methods that are called but onCreate...