所以我创建了我的Platform
类的实例:
//platform initialization
static Platform p;
//method to fill in the platform
public void makePlatform() {
double x = 100;
double y = 800;
Color c;
//platform is black
c = new Color(1,1,1);
p = new Platform(x,y, c);
}
而且我正在其他方法中使用这些变量:
public void run() {
while(true) {
//the control array is boolean for controls
if(controls[1])
p.x++;
if(controls[0])
p.x--;
if (p.x > 335 || p.x < 0) {
p.x = -p.x;
}
}
}
我在指向p.x
的行时遇到了很多异常。实例化有什么问题?