gpt4 book ai didi

JavaFx文本移动动画

转载 作者:行者123 更新时间:2023-12-01 09:29:24 27 4
gpt4 key购买 nike

嗨,我想做这样的事情:
我有文本,我希望文本始终从右向左移动。我想将移动文本的边界设置为 Pane 边界。现在我有了这个,但它没有按照我想要的方式工作

  public static void start(Text msg) {
msg.setTextOrigin(VPos.TOP);
double sceneWidth = Config.xSize;
double msgWidth = msg.getLayoutBounds().getWidth();
KeyValue initKeyValue = new KeyValue(msg.translateXProperty(), sceneWidth);
KeyFrame initFrame = new KeyFrame(Duration.ZERO, initKeyValue);
KeyValue endKeyValue = new KeyValue(msg.translateXProperty(), -1.0
* msgWidth);
KeyFrame endFrame = new KeyFrame(Duration.seconds(50), endKeyValue);
Timeline timeline = new Timeline(initFrame, endFrame);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();

我想在我的应用程序中从右到左放置幻灯片文本

最佳答案

您不需要将 KeyValue endKeyValueKeyFrame endFrame --> 删除它们。在 timeline.play(); 之前添加 timeline.setAutoReverse(true);

时间轴时间轴 = new Timeline(initFrame, endFrame); --> 时间轴时间轴 = new Timeline(initFrame);

希望我能帮助你。

编辑:

initFrame 的持续时间更改为 Duration.seconds(50) 或其他值。

关于JavaFx文本移动动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39571550/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com