Game Development Reference
In-Depth Information
Interactivity: Wiring the InvinciBagel
Buttons for Use
You need to replace the system writing to the console code in all these duplicated but-
ton event-handling structures with calls to the .setImage() method so that you can set
the image-compositing plate ImageView to the Image object that holds the digital im-
age asset you want to overlay the InvinciBagel backplate artwork created by Pat Har-
rington. You have already written this code construct twice in the createS-
plashScreenNodes() method, so you can copy the line of code directly above the two
Image object instantiations you just wrote, if you want a shortcut.
The
.setOnAction()
event-handling Java code structures would therefore look like
this:
helpButton
.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
splashScreenTextArea.setImage(
instructionLayer
);
}
});
scoreButton
.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
splashScreenTextArea.setImage(
scoresLayer
);
}
});
legalButton
.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
splashScreenTextArea.setImage(
legalLayer
);
}
});
As
Figure 6-11
demonstrates, your event-handling code is error free, and you are
ready to run and test again!