Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 10 ■ User InterfaCe DesIgn InteraCtIvIty: event hanDlIng anD ImagIng effeCts

Figure 10-17 shows my Run ➤ Project Button handler testing work process, showing both a drop
shadowing effect and the hue (color) shifting in place in the Disclaimers Button control, refining the design
even further. I clicked back and forth between all the different Button elements to make sure that all of the
attributes are not resetting any other Button screen design attributes in a way that is not desirable, which is
the reason that I put all of the correct variables in all the event handling code bodies so that no method call
has a setting overlooked (not specified/passed).


The final modification you will need to make is to your creditButton.setOnAction() event handling
structure to make everything on the screen a nice shade of blue. This can be achieved by color shifting the
hue of your logo 90 percent in the negative direction around a color wheel. The code for your creditButton
event handling Java statements is shown highlighted in the middle of Figure 10-18 and should look like the
following:


creditButton.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent event) {
infoOverlay.getChildren().clear();
infoOverlay.getChildren().addAll(credText, codeText);
infoOverlay.setTranslateY( 240 );
infoOverlay.setTranslateY( 370 );
uiLayout.setBackground(Background.EMPTY);
boardGameBackPlate.setImage(creditLayer);
logoLayer.setEffect(colorAdjust);
colorAdjust.setHue(-0.9);
}
});


Figure 10-17. Use the Run ➤ Project work process and make sure that the color hue shift matches the rest of
the design

Free download pdf