Game Development Reference
In-Depth Information
You might be thinking, well, since this is a great way to get rid of import static
statements in my Bagel.java class, why don't I use this same approach to also get rid of
the static Bagel iBagel declaration in my InvinciBagel.java class, as well as the im-
port static statement that is used in the GamePlayLoop.java class to access the static
iBagel Bagel object? Wow, that is a fantastic idea, folks, I just wish that I had thought
of it! In fact, let's do that right now!
Removing a Static iBagel Reference: Revise the
Handle() Method
As you can see in Figure 12-7 , we still have quite a few InvinciBagel variables de-
clared using the static keywords that are not, in fact, constants. Before this chapter is
over we will have eliminated these, so that only our WIDTH and HEIGHT constants
use the static modifier keyword. Since we are going to pass the InvinciBagel object ref-
erence to the GamePlayLoop class using the Java this keyword inside of the
GamePlayLoop() constructor method, which means that we can remove the static
keyword from the Bagel iBagel object declaration statement at the top of the Invin-
ciBagel class. This can be accomplished using the following variable declaration,
which is shown (highlighted) in Figure 12-7 :
Bagel iBagel;
Figure 12-7 . Remove the Java static modifier keyword from in front of your Bagel iBagel object declaration statement
 
 
Search WWH ::




Custom Search