Game Development Reference
In-Depth Information
My work process for making the other eight lines of variable declarations private rather
than package protected was to place the private Java access control keyword in front of
the (simple or compound) variable declaration, and then use the Run Project work
process (or click the green play icon at the top of NetBeans, which is faster) to test the
code and see if all of the features, including the Button UI, splashscreens and character
movement, work as they have been, using package protected access control. If for
some reason at a later point in the software development we need to remove the private
modifier or replace it with a different modifier keyword for any reason, we can, but it is
best to work from a place of total object encapsulation if possible from the start, and
then open up the object if we need to later on. The Java code statements for making all
data fields inside of our InvinciBagel class encapsulated are:
private Scene scene;
private Image splashScreen, instructionLayer, legalLayer,
scoresLayer;
private Image iB0, iB1, iB2, iB3, iB4, iB5, iB6, iB7, iB8;
private ImageView splashScreenBackplate,
splashScreenTextArea;
private Button gameButton, helpButton, scoreButton,
legalButton,;
private Insets buttonContainerPadding;
private GamePlayLoop gamePlayLoop;
private CastingDirector castDirector;
As you can see in Figure 12-12 , the code for all of the classes and modifications we
have made thus far are error-free, and we are ready to build more complex Java state-
ments that control our primary character sprite on top of technically correct Java code
that follows industry standard Java 8 programming practices.
 
Search WWH ::




Custom Search