如何在关键帧之间添加延迟?如果卡不匹配,我希望用户在卡关闭之前看到卡的正面0.6秒。这是我在底部试过的代码,但不起作用。
KeyFrame start = new KeyFrame(
Duration.ZERO,
new KeyValue(imageView.scaleXProperty(), 1.0));
KeyFrame middle = new KeyFrame(
Duration.millis(150),
e -> imageView.setImage(image),
new KeyValue(imageView.scaleXProperty(), 0.0)
);
KeyFrame end = new KeyFrame(
Duration.millis(300),
new KeyValue(imageView.scaleXProperty(), 1.0));
new Timeline(start, middle, end).play();
KeyFrame start = new KeyFrame(
Duration.ZERO,
new KeyValue(imageView.scaleXProperty(), 1.0));
KeyFrame middle = new KeyFrame(
Duration.millis(150),
e -> imageView.setImage(image),
new KeyValue(imageView.scaleXProperty(), 0.0)
);
KeyFrame delay = new KeyFrame(
Duration.millis(600)
);
KeyFrame end = new KeyFrame(
Duration.millis(300),
new KeyValue(imageView.scaleXProperty(), 1.0));
new Timeline(start, middle,delay, end).play();
1条答案
按热度按时间ego6inou1#
注:以下假设卡是“按比例放大”和“按比例缩小”。考虑到你的使用,我不确定这是你真正想要的
Duration.ZERO
在这个问题上。如果你想要卡片立即弹出,那么移除动画中的比例;只需显示卡,然后开始动画(在PauseTransition
是顺序设置中的第一个)。使用
SequentialTranition
,PauseTransition
,和ScaleTransition
对你有利。例如:如果希望缩放变换具有相同的持续时间,则可以将上述过程简化为: