Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 17 ■ i3D Game Square SeleCtion: uSinG the piCkreSult ClaSS with 3D moDelS

Go back into your createSceneProcessing() method and add the rotSpinner.setByAngle() method calls
using the negative angle values used in the rotGameBoard.setByAngle() method calls, using this code, also
shown in Figure 17-18:


if (picked == spinner) {
int spin = random.nextInt(4);
if (spin == 0) {
rotGameBoard.setByAngle(1080);
rotSpinner.setByAngle(-1080); // Zero degrees minus 1080
}
if (spin == 1) {
rotGameBoard.setByAngle(1170);
rotSpinner.setByAngle(-1170); // -1080 minus 90 degrees is -1170
}
if (spin == 2) {
rotGameBoard.setByAngle(1260);
rotSpinner.setByAngle(-1260); // -1080 minus 180 degrees is -1260
}
if (spin == 3) {
rotGameBoard.setByAngle(1350);
rotSpinner.setByAngle(-1350); // -1080 minus 270 degrees is -1350
}
rotGameBoard.play();
rotSpinner.play();
}

Free download pdf