Here is the problem of the day.
I hijacked the PlantManager to create cubes instead of plants. I already found a way to create them wherever I want, but now gotta move them. To do this, I need to select them.
My guess was to use the array that is created in the manager. My "moveCube" fonction is in the CarTest file and needs to modify the cubes in the CubeManager ("Cube" replaces "Plant"). I wrote the function below to select the cubes:
public Cube CubeSelect(int numero) {
return cubes[numero];
}
but I can't use it in the CarTest file. When launching the game, it crashes with:
Exception in thread "main" java.lang.NullPointerException
my function looks a bit like this:
public void moveCube(int num) {
if (cubeleft) {
cubeMan.CubeSelect(num).turnLeft();
}
if (cuberight) {
cubeMan.CubeSelect(num).turnRight();
}
where cubeleft and cuberight are event. the problem comes from the "cubeMan. ..."
Any idea ?
thx in advance