Here is my following code:
public void start(Stage primaryStage) throws Exception {
Pane root = new Pane();
Scene scene = new Scene(root, 500, 600);
Random rand = new Random();
int random = rand.nextInt(100-5)+5;
Circle circle = new Circle(0, 10, random);
circle.setFill(Color.RED);
root.getChildren().add(circle);
Timeline timeline = new Timeline(new KeyFrame(
Duration.seconds(2),
new KeyValue(circle.translateXProperty(), 600)
));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.setAutoReverse(false);
timeline.play();
primaryStage.setScene(scene);
primaryStage.show();
}
In this code it only update the random value once, but I want it to update random value after each cycle. Is there any way I can update my random value after each cycle? Any help is appreciated!
Aucun commentaire:
Enregistrer un commentaire