如何让 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() 方法就是动画。它本质上是一个轮子在旋转。该方法会打印一些代码,并在某些情况下重新激活按钮。然而,这是瞬时的。我希望动画在下一个方法运行之前完成,因为文本很快或按钮再次打开并可以中断操作。
您可以使用
RotateTransition rotateTransition = new RotateTransition();
rotateTransition.setOnFinished(e -> yourMethod())
rotateTransition.play();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)