在进入下一个方法之前,等待JavaFX动画方法完成

5
我该如何让JavaFX在一个带有动画的方法完成后等待再执行下一个方法?我的代码如下:
public void spinWheel(){
        RotateTransition rotation = new 
        rotation.setByAngle(-(720+(15*(i+(24-finalIndex)))));
        rotation.play();
        wheelResult=wheel.spinWheel(i);

spinButton.setOnAction(e->{
    spinButton.setDisable(true);
    wheelGui.spinWheel();
    spinGame();
    });

spinwheel()方法是一种动画效果,类似于一个转盘在旋转。该方法之后会打印一些代码,并在某些情况下重新激活按钮。然而,这是瞬间完成的。我希望在下一个方法运行之前动画能够完成,因为文本出现得太快或按钮再次开启可能会中断操作。


如果两者都是动画,请考虑使用 SequentialTransition - fabian
1个回答

4
您可以使用

标签

RotateTransition rotateTransition = new RotateTransition();
rotateTransition.setOnFinished(e -> yourMethod())
rotateTransition.play();

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接