JavaFX onclick 转换

发布于 2024-09-06 00:42:39 字数 416 浏览 4 评论 0原文

我试图通过单击两个按钮之一来调用转换。它实际上正在工作,但是由于某些原因我只能调用一次转换。有一个矩形我想从 A 移动到 B,B 到 A,然后再从 A 移动到 B。

function button2Action(): Void {
    oo.play();
}

function testani1(): Void {
    ooo.play();
}     

var oo = TranslateTransition {
     duration: 1s
     node: rectangle3
     fromY: 0
     toY: 70
}

var ooo = TranslateTransition {
    duration: 1s
    node: rectangle3
    fromY: 70
    toY: 0
}

I'm trying to invoke a transition by clicking on one of the two buttons. It is actually working however, i can only call the transition once for some reasons. There is a rectangle I would like to move from A to B, B to A and again from A to B.

function button2Action(): Void {
    oo.play();
}

function testani1(): Void {
    ooo.play();
}     

var oo = TranslateTransition {
     duration: 1s
     node: rectangle3
     fromY: 0
     toY: 70
}

var ooo = TranslateTransition {
    duration: 1s
    node: rectangle3
    fromY: 70
    toY: 0
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

路还长,别太狂 2024-09-13 00:42:39

你应该使用 ooo.playFromStart();第一次播放后,过渡“播放头”位于末尾,您必须“倒回”它以进行后续播放。

you should use ooo.playFromStart(); after the first playback the transition "play-head" is at the end and you have to "rewind" it for subsequent playbacks.

花开半夏魅人心 2024-09-13 00:42:39

我已经找到问题并回答我的问题了。我已将转换放入函数内,现在它正在工作。

I have found the problem and answer my question. I have put the transitions inside the function and it's working now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文