Pro Java 9 Games Development Leveraging the JavaFX APIs

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

The next step in this implementation of your ColorAdjust Effect object is to add the
.setEffect(colorAdjust) method call off of your logoLayer ImageView object, inside the helpButton.
setOnAction() event handler. This will shift the brown colored pixels in the transparent logo PNG32 image
to be green, while leaving the transparent pixels alone, as they have zero color value (and maximum
transparency value). If these pixels had been defined using a partial color value and a partial transparency
value, then the partial color values would be shifted forward 40 percent.
I have added this .setEffect() method call right after your boardGameBackPlate.setImage(helpLayer);
method call since we now need to color shift the logo image composite layer, as you can see highlighted in
Figure 10-13. The logoLayer object’s Effect object is set to the colorAdjust object, which is then set to a Hue
value of 0.4 (40 percent).


Figure 10-13. Use a Run ➤ Project work process to make sure that the drop shadow special effects are working
well

Free download pdf