-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathController2.java
69 lines (60 loc) · 1.93 KB
/
Controller2.java
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
69
package com.example.javafxproject.CarGame;
import javafx.animation.FadeTransition;
import javafx.animation.Transition;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.fxml.Initializable;
import javafx.util.Duration;
import java.net.URL;
import java.util.ResourceBundle;
public class Controller2 implements Initializable {
@FXML
private Pane pane;
@FXML
private Text text;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
pane.setBackground(new Background(new BackgroundFill(Color.BLACK, null, null)));
FadeTransition transition = new FadeTransition(Duration.seconds(2), text);
transition.setCycleCount(Transition.INDEFINITE);
transition.setFromValue(1);
transition.setToValue(0.1);
transition.setAutoReverse(true);
transition.play();
}
@FXML
Label score;
@FXML
Label maxScore;
@FXML
void exit(ActionEvent event) {
Stage stage = (Stage) pane.getScene().getWindow();
stage.close();
}
@FXML
void play(Event event) {
// System.out.println("Pressed Continue");
try {
Parent root = FXMLLoader.load(getClass().getResource("/CarGame.fxml"));
Stage stage = (Stage)pane.getScene().getWindow();
stage.setScene(new Scene(root));
}
catch (Exception e){
System.out.println(e);
}
}
}