如何用SWING写一个自由落体

来源:百度知道 编辑:UC知道 时间:2024/06/22 00:46:56
如题了~
就是运动物体的JFrame实现

public class FlyUp extends Thread {

public void run() {
this.flyUp();
}

public synchronized void flyUp() {
while (Plane.isUpMove && Plane.plane_y >= 0) {
try {
Thread.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
Plane.plane_y-=2;
Fly.jl_plane.setLocation(Plane.plane_x, Plane.plane_y);
}
this.stop();
}
}

这是我做的一个java飞机游戏中飞机向上飞的代码 希望能给你些思路