Game Development Reference
In-Depth Information
Figure 12-12 . Make all of the variable declarations after the iBagel Bagel object declaration use private access con-
trol
Next, we will get back into our Bagel.java class, and the .update() method, and start
to refine (and organize) that code into more logical methods, so that our .update()
method becomes more of a “top-level” method, that calls lower-level method “Java
code blocks” that implement things such as key event processing, character movement,
screen boundaries, sprite Image state, and so on.
This will allow us to put a more complex “workload” on the Bagel character's .up-
date() method by calling logical methods such as .setXYLocation() , .moveInvinciBa-
gel() , and .setBoundaries() , and later on during this topic, .setImageState() , .check-
ForCollision() and .playAudioClip() for example. In this way, your .update() method
calls other methods containing logical code blocks. This keeps your Java code well or-
ganized and makes programming logic easier to visualize.
Organizing the .update() Method:
.moveInvinciBagel()
 
Search WWH ::




Custom Search