28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 16 ■ Collision Detection: Creating SVG Polygons for the Game Actors and Writing Code to Detect Collision<br />

Figure 16-43. Showing the Group Scene Graph result (left) and corrective modification to HBox, iBagel and Prop (right)<br />

Replace the 0,0 XY location in the iBagel instantiation call to the Bagel() class constructor with WIDTH/2 and<br />

HEIGHT/2 respectively. This uses screen size constants and calculation code inside of a constructor method call,<br />

which will place the iBagel at the center of the screen. Add some different numbers in the Prop object instantiations as<br />

well, to place these tiles at different areas of the screen so we can develop some scoring code next as the InvinciBagel<br />

picks them up. Finally, replace the .setAlignment(Pos.BOTTOM_LEFT); method call with a .setLayoutY(365);<br />

method call to implement fixed positioning of the HBox UI Button elements back where they were before when we<br />

were using StackPane. If you use the Run ➤ Project work process, you will see the result shown on the right half of<br />

Figure 16-43.<br />

Figure 16-44. Use .setLayoutY() method to position HBox, WIDTH/2 and HEIGHT/2 to position iBagel, and new Prop X,Y<br />

388<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!