JavaFX RotateTransition indefinite halts

2019-05-06 17:46发布

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();

1条回答
可以哭但决不认输i
2楼-- · 2019-05-06 18:18

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.

Use the LINEAR interpolator instead to get a animation with constant speed:

rt.setInterpolator(Interpolator.LINEAR);
查看更多
登录 后发表回答