Hi there,
i wanted to make a little chess game but there’s a Nullpointer-Exception.
I think the initialization order is the problem.
The nodes and materials are created in the Main class.
private static ChessField chessField;
public Material matBrownField;
public Node chessFieldNode;
public static void main(String[] args) {
chessField = new ChessField();
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
init();
chessField.makeChessField();
}
This is the derived ChessField class, where the NullPointerException is thrown at the chessFieldNode line:
public class ChessField extends Main{
public ChessField(){
super();
}
private void makeWoodenFrame(){
for (float x=0; 8>=x; x++) {
chessFieldNode.attachChild(makeBox(new Vector3f(x, -.025f, 0), matBrownField));
}
}
What’s the reason for the Exception?