JavaFX RotateTransition无限期停止 [英] JavaFX RotateTransition indefinite halts
本文介绍了JavaFX RotateTransition无限期停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码的问题是两个动画之间存在大约半秒的暂停。我希望节点能够连续旋转。
The problem with the code below is that between two animations there is a pause of about half a second. I'd like the node to spin continuously.
RotateTransition rt = new RotateTransition(Duration.seconds(2), syncNode);
rt.setFromAngle(0);
rt.setToAngle(360);
rt.setCycleCount(Animation.INDEFINITE);
rt.play();
推荐答案
Interpolator
默认使用旋转在开始时加速并在结束时减速,这就是你得到你描述的行为的原因。
The Interpolator
used by default makes the rotation "speed up" at the start and "slow down" at the end, which is why you get the behaviour you described.
使用 LINEAR
插值器以获得恒定速度的动画:
Use the LINEAR
interpolator instead to get a animation with constant speed:
rt.setInterpolator(Interpolator.LINEAR);
这篇关于JavaFX RotateTransition无限期停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文