JavaFX onclick 转换
我试图通过单击两个按钮之一来调用转换。它实际上正在工作,但是由于某些原因我只能调用一次转换。有一个矩形我想从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你应该使用 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.
我已经找到问题并回答我的问题了。我已将转换放入函数内,现在它正在工作。
I have found the problem and answer my question. I have put the transitions inside the function and it's working now.