Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 15 ■ 3D Gameplay UI CreatIon: UsInG the sphere prImItIve to Create a UI noDe

The new Java 9 statement for your diffuse25 object instantiation should look like the following Java
code, which is also highlighted in yellow and blue in Figure 15-16:


diffuse 25 = new Image("/gameboardspin.png", 512 , 512 , true, true, true);


The next thing that needs to be done is to “tweak” all the spinner object configuration settings to make
the Sphere primitive a bit larger and move it closer to the corner of the screen so that it’s well out of the way
of the game board. I made the radius 64 and the Y translation -512 to move it further up. I found the rotation
value of 30 degrees centers the word SPIN. The Java code, which is also highlighted in Figure 15-17, should
look like the following:


Sphere spinner;
...
spinner = new Sphere( 64 );
spinner.setMaterial(Shader25);
spinner.setTranslateX(-200);
spinner.setTranslateY(-512);
spinner.setRotationAxis(Rotate.Y_AXIS);
spinner.setRotate( 30 );


Figure 15-16. Modify the width and height resolution parameters and change them from 256 pixels to 512
pixels each

Free download pdf