Game Development Reference
In-Depth Information
ateGameActors() method and the constructor method calls that we created in our cus-
tom Actor and Hero subclasses, such as the Bagel.java class we created in Chapter 10 .
Once we have the actors created, we can add them to the Scene Graph using .ad-
dGameActorNodes() as well as adding them to the game cast using the .createCast-
ingDirection() method. At the end, we create and start the GamePlayLoop object by
calling the .createStartGameLoop() method. The .createSplashScreenNodes() and .ad-
dNodesToStackPane() are at the end, as they won't be added to now that the splash-
screen content production work has been completed. The method call code that we'll
add during this chapter looks like the following:
createSceneEventHandling();
loadImageAssets();
createGameActors();
addGameActorNodes();
createCastingDirection();
createSplashScreenNodes();
addNodesToStackPane();
createStartGameLoop();
Let's get down to business and start implementing this code redesign process for
the InvinciBagel.java class.
The Scene Event Handling Method: .createS-
ceneEventHandling()
The first thing that we will want to do is to move the event handling for our game play
into its own method, which we will call .createSceneEventHandling() . The reason
that I am creating a method for the creation of Scene object event handling is because
if later on you wanted to add other types of input events into your game, such as mouse
events or drag events, you will have a logical method already in place which can hold
this event-related Java code.
This new Java code, which can be seen in Figure 11-2 , will involve taking your
scene.setOnKeyPressed() and scene.setOnKeyReleased() method handling struc-
tures, created in Chapter 9 , out of your .createSplashScreenNodes() method, and pla-
cing them into their own method structure. Later we'll relocate all ActionEvent hand-
lers, which are in the .start() method, and actually belong inside the .createS-
plashScreenNodes() method where they would be grouped with the other splashscreen
 
Search WWH ::




Custom Search