JavaFX 时间线不准确
我在 JavaFX 中有两个时间线,用于在屏幕上移动图像。一种是在onMouseEntered函数中将图像向左移动,另一种是在onMouseExited函数中将图像向右移回。关键帧的translateX从0开始到10,另一个从10开始到0。问题是两个时间轴不会将图像移动相同的距离,因此如果您多次激活它,它就会开始向右爬行。我在这里缺少什么吗?如何设置动画使其前后移动相同的距离?
I have two timelines in JavaFX that moves an image on the screen. One is in the onMouseEntered function to move the image left, and the other in the onMouseExited function to move the image back to the right. The keyframe has translateX starting at 0 and going to 10, and the other starts at 10 and goes to 0. The problem is that the two timelines don't move the image the same distance, so that if you activate it several times it starts creeping to the right. Is there something I'm missing here? How do I set up an animation so that it moves the same distance forward and backward?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了,回程应该使translateX变成0,而不是-10
Figured it out, the return trip should make translateX go to 0, not to -10