0
好吧,所以當我點擊鼠標時,我的圖片就會沿着y軸向下移動,我唯一的問題是我不知道如何讓它停止點擊屏幕底部,有人可以幫忙嗎?正在停止圖像移動
import java.awt.Point;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class Control extends BasicGameState {
public static final int ID = 1;
public Methods m = new Methods();
public Point[] point = new Point[(800 * 600)];
int pressedX;
int pressedY;
int num = 0;
String Build = "1.1";
public void init(GameContainer container, StateBasedGame game) throws SlickException{
}
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
for (Point p : point) {
if (p != null) {
m.drawParticle(p.x, p.y += 1);
}
}
g.drawString("Particle Test", 680, 0);
g.drawString("Build: " + Build, 680, 15);
g.drawString("Pixels: " + num, 10, 25);
}
public void update(GameContainer container, StateBasedGame game, int delta) {
}
public void mousePressed(int button, int x, int y) {
pressedX = x;
pressedY = y;
num = num + 1;
point[num] = new Point(pressedX, pressedY);
}
public int getID() {
return ID;
}
}
謝謝,現在你有什麼想法,我會讓它停止向下移動? – user1610541
在第二個例子中,如果'py'等於或大於可用高度,那麼它的y位置不應該再次更新......顯然,如果將它從數組中移除(將數組位置設置爲null),它不會只有永遠不會再移動,它不會被畫;) – MadProgrammer
但我可以讓它保持不動? – user1610541