Another issue with the "car" example: moving the p

Started by drounal, May 16, 2006, 09:09:41 PM

Previous topic - Next topic

drounal

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

Melssj5

What movement are you trying to do!, I mean, moving all the cubes on a specific way or you need to move just some of them selecting by a criteria?
Nada por ahora

drounal

sorry for posting so many messages. besides, I found a way to work out this issue by myself.
thx again