我正在研究javaFx应用程序。如何进行直线转换?我有两个矩形,我想要第一个矩形转到第二个矩形。 这是不起作用的代码:
Rectangle r1 = rectangles.get(numbers[0]);
Rectangle r2 = rectangles.get(numbers[1]);
TranslateTransition translateTransition = new TranslateTransition();
translateTransition.setNode(r1);
translateTransition.setDuration(Duration.millis(1000));
translateTransition.setFromX(r1.getX());
translateTransition.setToX(r2.getX());
TranslateTransition translateTransition2 = new TranslateTransition();
translateTransition2.setNode(r2);
translateTransition2.setDuration(Duration.millis(1000));
translateTransition2.setFromX(0);
translateTransition2.setToX(r1.getX() - r2.getX());
translateTransition2.play();
translateTransition.play();