Game Development Reference
In-Depth Information
As long as we are making our InvinciBagel.java class completely encapsulated,
let's make the StackPane root variable private as well, and get rid of the static modifier.
Since I have moved the StackPane object named root back up into the .start() menu
from the .createSplashScreenNodes() method, there is no good reason for a static
modifier keyword. I am trying to remove all static modifiers (that are not constants)
and “privatize” this class as much as I can.
Removing the Rest of the Static Variables: StackPane
and HBox
Now I am going to start going right down the variable declaration lines of code at the
top of the InvinciBagel.java class starting with the Boolean variables that we made
private (which were public static), and see which of these variables I can make private
instead of package protected static (which StackPane and HBox are currently), or
which are package protected, and can be made private . A private variable “encapsu-
lates” that variable's data inside of the class (object) itself; in this case, this would be
the InvinciBagel.java code that we're currently refining. A package protected variable
encapsulates the data inside of the package; in this case that would be the invincibagel
package. The new Java statement for declaring the StackPane object named root, which
is a root element of the Scene Graph, to be a private member of the InvinciBagel.java
class (only), would be accomplished using the following code, shown in Figure 12-10 .
private StackPane root;
 
Search WWH ::




Custom Search