JavaFX:循环之间的旋转动画延迟

时间:2016-03-18 12:56:32

标签: java animation javafx

我使用以下代码基于RotatedTranstion为ImageView创建了动画:

link_to

这会产生以下动画:

Rotation in Action

正如您在GIF动画中所注意到的那样,动画并不是连续的,即动画周期之间会有一个小的延迟(暂停)。

我试图查看API,但无法弄清楚导致此延迟的原因以及我如何摆脱它。

2 个答案:

答案 0 :(得分:6)

每个循环之间的明显暂停是由interpolator引起的,enter image description here默认使用Interpolator.EASE_BOTH(因此它在每个循环结束时减速并在开始时加速)。

要删除此功能,只需将插补器设置为Interpolator.LINEAR

rotateTransition.setInterpolator(Interpolator.LINEAR);

答案 1 :(得分:3)

每个Transition周期的加速和减速时间由Interpolator控制。 Transition使用的默认InterpolatorInterpolator.EASE_BOTH

您需要线性插值,因此请将其添加到您的代码中:

rotateTransition.setInterpolator(Interpolator.LINEAR);
相关问题