【发布时间】:2020-01-09 02:52:20
【问题描述】:
这是我的代码
ImageView contImg = new ImageView();
Timeline timeline = new Timeline(
new KeyFrame(javafx.util.Duration.ONE, new KeyValue(contImg.imageProperty(), cartas.get(0).getImg())),
new KeyFrame(javafx.util.Duration.ONE, new KeyValue(contImg.imageProperty(), cartas.get(1).getImg())),
new KeyFrame(javafx.util.Duration.ONE, new KeyValue(contImg.imageProperty(), cartas.get(2).getImg())),
new KeyFrame(javafx.util.Duration.ONE, new KeyValue(contImg.imageProperty(), cartas.get(3).getImg())));
timeline.play();
但问题是图像不会改变 (cartas 是一个 Arraylist,其中每个购物车都有一个 image how 属性)
【问题讨论】:
-
您是否尝试过仅在图像视图上设置图像以确保 cartas 包含不同的图像?
-
您正在使用 Duration.ONE,即 1 毫秒,它可能只是在它们之间循环以快速查看。为什么不使用
Duration.seconds(n)? -
我在这里发布了一个方法:stackoverflow.com/a/51611368/2991525