オブジェクトの配列を作成するjava.lang.NullPointerException
ときに問題が発生しますが、それに何かをアドレス指定しようとすると、が発生します。
これは問題のあるクラスです。
public class Blocks {
public static Block[] b = new Block[8];
public Blocks() throws IOException {
new Air (b[0]);
new Stone(b[1]);
new Grass(b[2]);
new Dirt (b[3]);
}
これはクラスBlockです。
public class Block {
private Texture Texture = null;
private int S = World.BLOCK_SIZE;
private boolean hasTexture = true;
private String texturePath = null;
public void setTexture(String path) throws IOException {
this.texturePath = path;
Texture = TextureLoader.getTexture("PNG", new FileInputStream(new File(path)));
}
public void draw(int Xa, int Ya) {
GL11.glTranslatef(Xa, Ya, 0);
//GL11.glRotatef(0, 0, 1, 0);
//GL11.glRotatef(0, 1, 0, 0);
if(hasTexture) {
Texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor3f(0.5f, 0.5f, 1);
//GL11.glNormal3f(0, 0, 1);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(0, S);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(S, S);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(S, 0);
GL11.glEnd();
}
}
void hasTexture(boolean b) {
this.hasTexture = b;
}
}
さらに情報/コードを提供する必要がある場合はお知らせください