JavaFX在转到下一个方法之前等待动画方法完成 [英] JavaFX wait for animation method to finish before going to next method

查看:230
本文介绍了JavaFX在转到下一个方法之前等待动画方法完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让JavaFX在移动到下一个方法之前等待一个动画完成的方法?所以我的代码如下:

How do I get JavaFX to wait for one method with an animation to finish before moving to the next method? So my code is as follows:

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()方法就是动画。它本质上是一个轮子旋转。该方法打印一些代码后,在某些情况下重新激活按钮。然而,这是瞬间的。我希望动画在下一个方法运行之前完成,因为文本变为快速或按钮再次打开并且可以中断操作。

So the spinwheel() methods is the animation. It is essentially a wheel spinning. The method after prints some code and in some cases reactivates the button. However this is instantaneous. I want the animation to finish before the next method runs as the text comes to fast or the button turns on again and can interrupt the action.

推荐答案

您可以使用

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

这篇关于JavaFX在转到下一个方法之前等待动画方法完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆