From eab202db1c5e93a5fa1efae6f964b495df4681e5 Mon Sep 17 00:00:00 2001 From: AcaciaMan Date: Sat, 11 Dec 2021 05:31:31 +0200 Subject: [PATCH] Fixed view movement --- src/main/java/sample/RaceView.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/sample/RaceView.java b/src/main/java/sample/RaceView.java index 91d1d42..d3390a1 100644 --- a/src/main/java/sample/RaceView.java +++ b/src/main/java/sample/RaceView.java @@ -12,6 +12,8 @@ public class RaceView { public Circle[] gates; + public boolean once = false; + public void translateViews() { circle.setTranslateY(-RaceView.views[0][1]); @@ -25,17 +27,20 @@ public void translateViews() { public void translateViews1(ParallelTransition pt) { - TranslateTransition translateTransition = - new TranslateTransition(new javafx.util.Duration(50.0), circle); - translateTransition.setByY(RaceView.views[1][1]); - pt.getChildren().add(translateTransition); - pt.play(); + if (!once) { + once = true; + TranslateTransition translateTransition = + new TranslateTransition(new javafx.util.Duration(1000.0), circle); + translateTransition.setByY(RaceView.views[1][1]); - for (int i = 0; i < Engine.gates.length; i++) { - gates[i].setTranslateY(RaceView.views[1][1]-100); - } + pt.getChildren().add(translateTransition); + pt.play(); + for (int i = 0; i < Engine.gates.length; i++) { + gates[i].setTranslateY(RaceView.views[1][1] - 100); + } + } } }