如何在不影响其他节点的情况下为DropShadow设置动画?

时间:2018-06-12 14:46:39

标签: java javafx javafx-8

我尝试为Node DropShadow制作动画,但它似乎影响了场景图中具有阴影效果的其他节点(和/或同一节点的实例)。我目前正在使用这种方法制作动画:

DropShadow shadow = (DropShadow) node.getEffect();
Timeline timeline = new Timeline();
timeline.getKeyFrames().setAll(
  new KeyFrame(Duration.ZERO,
    new KeyValue(shadow.radiusProperty(), shadow.getRadius()),
    new KeyValue(shadow.spreadProperty(), shadow.getSpread()),
    new KeyValue(shadow.offsetXProperty(), shadow.getOffsetX()),
    new KeyValue(shadow.offsetYProperty(), shadow.getOffsetY())
  ),
  new KeyFrame(Duration.millis(1000),
    new KeyValue(shadow.radiusProperty(), NEW_DROP_SHADOW.getRadius()),
    new KeyValue(shadow.spreadProperty(), NEW_DROP_SHADOW.getSpread()),
    new KeyValue(shadow.offsetXProperty(), NEW_DROP_SHADOW.getOffsetX()),
    new KeyValue(shadow.offsetYProperty(), NEW_DROP_SHADOW.getOffsetY())
  )
);

在JavaFX中为阴影效果设置动画的正确方法是什么?

0 个答案:

没有答案
相关问题