📄 fallingobject.java~
字号:
import objectdraw.ActiveObject;import objectdraw.Drawable2DInterface;// FallingObject class to encapsulate the behavior of ActiveObjects that// fall until they reach a certain y-position then disappear//// Version with a hitBottom method that can easily be overridden//// Jim Teresco, April 2002//public class FallingObject extends ActiveObject { protected static final int DELAY_TIME = 33; // Fall until we get to this position protected int fallToPos; // how fast? protected double ySpeed; // what is falling? protected Drawable2DInterface object; // Constructor // Parameters: thePos - how far down the object should fall // theSpeed - how far to fall each time around public FallingObject(int thePos, double theSpeed) { ySpeed = theSpeed; fallToPos = thePos; // note that it is the responsibility of the derived class // to call start(); } // The run method public void run() { while (object.getY() < fallToPos) { pause(DELAY_TIME); object.move(0, ySpeed); } hitBottom(); } // default "hit bottom" behavior - may be overridden protected void hitBottom() { object.removeFromCanvas(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -