-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountDown.java
40 lines (37 loc) · 1.14 KB
/
CountDown.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
import javafx.application.Platform;
public class CountDown implements Runnable{
public static Thread mythread;
private int seconds;
private Controller controller;
public void run()
{
try{
// System.out.println("Thread Started Running...");
while (!Thread.interrupted()){
if(seconds==0){
Platform.runLater(new Runnable() {
@Override
public void run() {
controller.gameOver(false);
}
});
return;
}
mythread.sleep(1000);
Platform.runLater(new Runnable() {
@Override
public void run() {
controller.timer_label.setText(Integer.toString(seconds));
}
});
seconds--;
}
}
catch (InterruptedException e){
}
}
public CountDown(int seconds, Controller controller){
this.seconds=seconds;
this.controller=controller;
}
}