如何使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();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句