现在我正在尝试进行赛车比赛。我希望汽车在某些时候减速并加速。我知道我需要创建4个路径转换,但是我不知道如何使用for循环创建4个。这是我的代码:
private void BlueCarMove(Group root, Node n) {
int x = Integer.valueOf(BlueCarSpeed.getText());
double y = x/100.0;
Path path = new Path();
MoveTo move = new MoveTo(-50, 85);
path.getElements().add(move);
LineTo line = new LineTo(475, 85);
path.getElements().add(line);
path.setStroke(Color.TRANSPARENT);
root.getChildren().add(path);
PathTransition pt = new PathTransition();
pt.setRate(y);
pt.setPath(path);
pt.setNode(n);
pt.play();
}