【发布时间】:2020-12-17 17:57:41
【问题描述】:
如何在关键帧之间添加延迟?如果卡片不匹配,我希望用户在卡片关闭前能看到卡片正面 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();
【问题讨论】:
-
只需添加另一个具有相同
KeyValue的KeyFrame。 -
我试图在它们之间添加它,但由于它没有任何操作,所以它不起作用
-
它不应该需要一个动作来工作。很难想象哪个框架在这里做什么,因为这不是完整的代码。您可以发布您尝试的代码吗?
-
我当然编辑了帖子
-
所有的持续时间都是相对于时间线的开始计算的,所以上面的持续时间应该是不正确的。
标签: java user-interface javafx