-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreBoard.java
More file actions
57 lines (50 loc) · 1.76 KB
/
ScoreBoard.java
File metadata and controls
57 lines (50 loc) · 1.76 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
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
/**
* ScoreBoard Class - creates the text "SCORE" and the score (value) itself
* extends StackPane so that it can create a single object made of more than one component (2 Texts) and allow it to be added to root
* @author Samu
*/
public class ScoreBoard extends StackPane {
private Text scoreValue;
/**
* Constructor of GameOver that creates and adds together the text score and the score value
*/
public ScoreBoard(String setScore) {
scoreValue = new Text(setScore);
getChildren().addAll(scoreValueProp(), scoreTextProp()); // puts text and rectangle together
}
/**
* Method that sets text properties of scoreValue
* @return scoreValue - text that represents the value of the score
*/
private Node scoreValueProp() {
scoreValue.setFill(Color.BLACK);
scoreValue.setFont(Font.font("Tw Cen MT Condensed", FontWeight.SEMI_BOLD, 50));
setAlignment(Pos.BASELINE_LEFT);
scoreValue.setTranslateY(40);
return scoreValue;
}
/**
* Method that sets text properties of scoreText
* @return scoreText - text "SCORE"
*/
private Node scoreTextProp() {
Text scoreText = new Text("SCORE");
scoreText.setFill(Color.BLACK);
scoreText.setFont(Font.font("Tw Cen MT Condensed", FontWeight.SEMI_BOLD, 40));
return scoreText;
}
/**
* Method that update score by setting the value of score to the text of scoreValue
* @param score - integer that represents the score converted into String
*/
public void updateScore(String score) {
scoreValue.setText(score);
}
}