Game Development Reference
In-Depth Information
next several pages of the chapter, is to change the public static boolean variable de-
claration compound statement to not use a static modifier, and instead of the public ac-
cess control modifier, to use the private keyword, as is shown here:
private boolean up, down, left, right;
As you can see in Figure 12-1 , this doesn't generate any red errors or yellow warn-
ing highlights in the code; however, it does generate wavy grey underlining. This signi-
fies that the code that is highlighted is not currently being used. Since the “convention”
or general rule in Java regarding static modifier keywords is to use them with con-
stants, such as we are in the first line of code, and thus, I am going to try and “encapsu-
late” the code in this InvinciBagel.java class as much as possible, by removing the stat-
ic modifiers (first), and making many of the other declarations private .
Figure 12-1 . Change the public static access modifiers for the boolean KeyEvent variables to be private access con-
trol
The code that we are going to put into place next will eliminate this wavy grey
highlighting, and in fact, we are going to have NetBeans write that code for us using
the Source Insert Code Getters and Setters work process, which we learned
about in Chapter 8 , when we created our Actor and Hero superclasses. The .is() and
.set() methods, which we are about to generate next, are the solution that allows us to
eliminate the public static variable declaration that was allowing your classes external
 
 
Search WWH ::




Custom Search