[英]Java fx slowly moving image
Currently i'm trying to make an image slowly slide using Java fx from one coordinate to another. 目前,我正在尝试使用Java fx使图像从一个坐标缓慢滑动到另一个坐标。 For this construction i'm using a pane and have added a shaft imageview and a elevator image to it.
对于这种构造,我使用的是窗格,并在其中添加了竖井图像视图和电梯图像。 I've been succesfull in changing the coordinates of the image but I want the image to slowly slide over to that position.
我一直在成功更改图像的坐标,但我希望图像缓慢滑到该位置。 As a result I added a loop that with a thread.sleep method to slow down the looping speed.
结果,我添加了一个带有thread.sleep方法的循环,以减慢循环速度。 Unforunately this does not give the desired effect.
不幸的是,这并没有达到预期的效果。
Hopefully one of you has a good suggestion I could use for this. 希望你们中的一个有很好的建议,我可以为此使用。 My loop:
我的循环:
Button een = new Button("1");
een.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
if(elevator.getY()>300){
while(elevator.getY()!=300){
elevator.setY(elevator.getY()-1);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(LayoutSample.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
});
Yours truly 敬上
没有循环,没有睡眠, TranslateTransition ,链接的javadoc包括一个示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.