-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpause.java
More file actions
68 lines (59 loc) · 2.67 KB
/
pause.java
File metadata and controls
68 lines (59 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Import all necessary classes for the pause screen
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
// This class contains everything required to create the pause page
class pause {
// Declaration and initialization of labels, buttons, vbox, and scene used in the class
Text pauseLabel = new Text("Game Paused");
Button resumeButton = new Button("Resume");
Button quitButton = new Button("Quit");
VBox buttonsVbox;
VBox pauseVbox;
Scene pauseScene;
// Method to set the pause scene
public void setPause() {
// Initialize the two font sizes
Font largeFont = Font.loadFont("file:PacMan/Resources/Font/pac.ttf", 50);
Font smallFont = Font.loadFont("file:PacMan/Resources/Font/pac.ttf", 25);
// Set styles for the Pause Label
pauseLabel.setFont(largeFont);
pauseLabel.setFill(Color.YELLOW);
// Set styles for both Resume and Quit Buttons
resumeButton.setFont(smallFont);
resumeButton.setStyle("-fx-text-fill: white;");
resumeButton.setBackground(null);
quitButton.setFont(smallFont);
quitButton.setStyle("-fx-text-fill: white;");
quitButton.setBackground(null);
// Create and style vbox which contains only the two button options
buttonsVbox = new VBox(15, resumeButton, quitButton);
buttonsVbox.setAlignment(Pos.CENTER);
buttonsVbox.setStyle("-fx-border-color: red; -fx-border-insets: 10; -fx-border-width: 3;-fx-border-style: dashed; ");
// Create the pauseVbox with the label and the buttons vbox
pauseVbox = new VBox(10, pauseLabel, buttonsVbox);
pauseVbox.setAlignment(Pos.CENTER);
pauseVbox.setStyle("-fx-background-color: black");
// Create the new Scene
pauseScene = new Scene(pauseVbox);
// On hover properties for both buttons so that it changes text color when the mouse is over the button
resumeButton.hoverProperty().addListener((obs, oldVal, newValue) -> {
if (newValue) {
resumeButton.setStyle("-fx-text-fill: blue;\n");
} else {
resumeButton.setStyle("-fx-text-fill: white ");
}
});
quitButton.hoverProperty().addListener((obs, oldVal, newValue) -> {
if (newValue) {
quitButton.setStyle("-fx-text-fill: red;\n");
} else {
quitButton.setStyle("-fx-text-fill: white ");
}
});
}
}