Rectangle backgroundRect = new Rectangle();
backgroundRect.setFill(Color.BLACK);
backgroundRect.setWidth(640);
backgroundRect.setHeight(400);
final FadeTransition fadeInSelection = new FadeTransition(Duration.millis(500));
final FadeTransition fadeOutBackground = new FadeTransition(Duration.millis(1000));
final VBox outerPane = new VBox();
outerPane.setAlignment(Pos.CENTER);
outerPane.setVisible(false);
outerPane.setOpacity(0.0);
outerPane.setPadding(new Insets(0, 15, 0, 15));
outerPane.setSpacing(20);
final ImageView background = new ImageView();
background.setCursor(Cursor.HAND);
background.setOpacity(1.0);
background.setImage(Assets.getBackground(Assets.IMAGE_SCREENS_GAME_SELECTION_BACKGROUND));
background.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent me) {
if (!outerPane.isVisible()) {
background.setCursor(null);
outerPane.setVisible(true);
fadeInSelection.play();
fadeOutBackground.play();
}
}
});
fadeInSelection.setCycleCount(1);
fadeInSelection.setFromValue(1.0);
fadeInSelection.setToValue(0.3);
fadeInSelection.setNode(background);
fadeOutBackground.setCycleCount(1);
fadeOutBackground.setFromValue(0.0);
fadeOutBackground.setToValue(1.0);
fadeOutBackground.setNode(outerPane);
Label numberOfPlayersLabel = new Label("NUMBER OF PLAYERS");
numberOfPlayersLabel.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_16));
numberOfPlayersLabel.setTextFill(Color.LIGHTGRAY);