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

Now I can add a rotSpinner.play(); Java statement to the conditional event handling construct,
without generating any errors, so that when the spinner UI is clicked, it spins alongside the game board
for the same amount of time and at the same rate. The completed Java code looks like this and is shown
highlighted in yellow in Figure 17-9:


private void createSceneProcessing() {
scene = new Scene(root, 1280, 640, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
scene.setCamera(camera);
scene.setOnMouseClicked(event->{
Node picked = event.getPickResult().getIntersectedNode();
if (picked != null) {
if (picked == spinner) {
rotGameBoard.play();
rotSpinner.play();
}
}
});
}


Figure 17-8. Copy and paste the rotSpinner object code under itself to create a rotSpinnerIn, and reference in
spinnerAnim

Free download pdf