Game Development Reference
In-Depth Information
Figure 16-43
.
Showing the Group Scene Graph result (left) and corrective modification to HBox, iBagel and Prop
(right)
Replace the 0,0 XY location in the iBagel instantiation call to the Bagel() class con-
structor with
WIDTH/2
and
HEIGHT/2
respectively. This uses screen size constants
and calculation code inside of a constructor method call, which will place the iBagel at
the center of the screen. Add some different numbers in the Prop object instantiations
as well, to place these tiles at different areas of the screen so we can develop some
scoring code next as the InvinciBagel picks them up. Finally, replace the
.setA-
lignment(Pos.BOTTOM_LEFT);
method call with a
.setLayoutY(365);
method call to implement fixed positioning of the HBox UI Button elements back
where they were before when we were using StackPane. If you use the
Run Pro-
ject
work process, you will see the result shown on the right half of
Figure 16-43
.
Figure 16-44.
Use .setLayoutY() method to position HBox, WIDTH/2 and HEIGHT/2 to position iBagel, and new
Prop X,Y