package net.gfx;
public class TileSet {
public final int TILES = 627;
class Tiles {
int x = 0, y = 0;
int w = 0, h = 0;
}
public Tiles tiles[] = new Tiles[TILES];
public TileSet() {
for (int i = 0, y = 0; i < TILES; i++) {
for (int x = 0; x < 1280; x =+ 25) {
if (x > 1280) {
x = 0;
y += 40;
}
else {
tiles[i].x = x; //ERROR CAUSED HERE
tiles[i].y = y; //TO HERE *Unknown reason*
tiles[i].w = 40;
tiles[i].h = 40;
}
}
}
}
}
我得到的错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.jump.Jump.<clinit>(Jump.java:8)
Caused by: java.lang.NullPointerException
at net.gfx.TileSet.<init>(TileSet.java:24)
at net.gfx.Graphics.<clinit>(Graphics.java:10)
... 1 more
我要做的基本上是在屏幕上创建一组图块。除了设置对象数组值之外,其他一切都有效。
我几乎在所有地方都进行了搜索,但没有找到任何东西。我打赌它可能是我错过的一些简单的事情。