Skip to content
Snippets Groups Projects
Commit 3eb6ed4f authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #48

parent b8413705
No related branches found
No related tags found
1 merge request!49merge power-ups into master
...@@ -562,6 +562,12 @@ public class LevelController ...@@ -562,6 +562,12 @@ public class LevelController
labelPause.setTranslateY(((gamePaneHeight - t.getLayoutBounds().getHeight()) / 2) + 125); labelPause.setTranslateY(((gamePaneHeight - t.getLayoutBounds().getHeight()) / 2) + 125);
anchorPane.getChildren().add(labelPause); anchorPane.getChildren().add(labelPause);
//pause all timedPowerUps
for(CountdownTimer currentTimer : timedPowerUps)
{
currentTimer.stop();
}
} }
private void restart() private void restart()
...@@ -571,6 +577,13 @@ public class LevelController ...@@ -571,6 +577,13 @@ public class LevelController
fps = 0; fps = 0;
anchorPaneGame.setOpacity(1.0); anchorPaneGame.setOpacity(1.0);
anchorPane.getChildren().remove(anchorPane.getChildren().size() - 1); anchorPane.getChildren().remove(anchorPane.getChildren().size() - 1);
//restart all timedPowerUps
for(CountdownTimer currentTimer : timedPowerUps)
{
currentTimer.start();
}
timer.start(); timer.start();
} }
......
...@@ -12,17 +12,33 @@ public class CountdownTimer ...@@ -12,17 +12,33 @@ public class CountdownTimer
{ {
private int count; private int count;
private HBox hbox; private HBox hbox;
private LevelController levelController;
private Timer timer; private Timer timer;
private TimerTask task;
private CountdownTimer self;
public CountdownTimer(int seconds, HBox hbox, LevelController levelController) public CountdownTimer(int seconds, HBox hbox, LevelController levelController)
{ {
this.count = seconds; this.count = seconds;
this.hbox = hbox; this.hbox = hbox;
self = this;
CountdownTimer self = this; start();
}
timer = new Timer(); public void addSecondsToTimer(int seconds)
TimerTask task = new TimerTask() {
this.count += seconds;
}
public HBox getHBox()
{
return hbox;
}
public void start()
{
task = new TimerTask()
{ {
@Override @Override
public void run() public void run()
...@@ -52,19 +68,10 @@ public class CountdownTimer ...@@ -52,19 +68,10 @@ public class CountdownTimer
} }
} }
}; };
timer = new Timer();
timer.schedule(task, 0, 1000); timer.schedule(task, 0, 1000);
} }
public void addSecondsToTimer(int seconds)
{
this.count += seconds;
}
public HBox getHBox()
{
return hbox;
}
public void stop() public void stop()
{ {
timer.cancel(); timer.cancel();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment