28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 11 ■ Moving Your Action Figure in 2D: Controlling the X and Y Display Screen Coordinates<br />

Notice that since the .loadImageAssets() method is called before the .createSplashScreenNodes() method, that<br />

we can still keep the last four lines of code in the method body that reference the loaded Image assets in place. This is<br />

because the splashScreen and instructionLayer Image objects have been created, and loaded with their digital image<br />

assets, in the top part of the .loadImageAssets() method. Since this method is called inside the .start() method before<br />

the .createSplashScreenNodes() method is called, these objects can be safely used inside of this method body.<br />

As you can see in Figure 11-10, the new method is error-free and all of the objects, including the HBox named<br />

buttonContainer, Button(s) named gameButton, helpButton, scoreButton and legalButton, and ImageView(s) named<br />

splashScreenBackplate and splashScreenTextArea, are all logically grouped together, and are now well organized.<br />

Figure 11-10. Copy .setOnAction() event handlers from the .start() method into the .createSplashScreenNodes() method<br />

Since we don’t have to do anything to your .addNodesToStackPane() method, we are finished with the code<br />

reorganization that we needed to do here, before we take this game to the next level of complexity! Every now and<br />

then, you need to go back and make sure that your programming logic is optimally structured, so that when you build<br />

more complex structures, you have a solid foundation to build upon, just like you’re building a real building structure.<br />

www.it-ebooks.info<br />

241

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!