0
所以我一直在努力讓我的盒子整天保存陣列中的位置,並最終以爲我想出了一些東西(有很多來自你們的幫助),它只是不工作...有人可以告訴我爲什麼嗎?粒子系統陣列
控制類:
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;
public void init(GameContainer container, StateBasedGame game) throws SlickException{
}
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
m.drawParticle(pressedX, pressedY);
}
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].x = pressedX;
point[num].y = pressedY;
}
public int getID() {
return ID;
}
}
方法類:
import org.newdawn.slick.Graphics;
public class Methods {
public Graphics g = new Graphics();
public int sizeX = 1;
public int sizeY = 1;
public void drawParticle(float x, float y){
g.drawRect(x, y, sizeX, sizeY);
}
}
請比「不工作」更具體。 –
什麼不起作用? – gigadot
@ user1610541當然:)我們想知道代碼是做什麼的嗎?您是否面臨任何錯誤?給出一些相關的信息,以便於做 – gks