-1

I'm working with LeapMotion. I have this code in my main class:

public void onFrame(Controller controller) {
    Frame frame = controller.frame();
    GestoPistola gesto;

    if (!frame.hands().isEmpty()) 
    {
        System.out.println("ENTER");
        gesto.reconocer(frame);
    }
…
}

And then, this is the class GestoPistola, which is the one that has to make all the job.

    public class GestoPistola {
       public enum ESTADO{
           DESCARGADA, CARGADA
       }

       ESTADO _estado;

       public void GestoPistola(){
           _estado = ESTADO.DESCARGADA;
       }

       public void reconocer(Frame f)
       {
           System.out.println("LET'S START");

           if (!f.hands().isEmpty()) {
               System.out.println("Hay mano");
               Hand hand = f.hands().get(0);
               FingerList fingers = hand.fingers();

               switch(_estado)
               {
                     …
               }
           }
        }
   }

So, the consol shows "ENTER", but never "LET'START".

I know it's a really simple question, but I'm not such an expert with JAVA.

Hope someone can help me!

Stultuske
  • 9,296
  • 1
  • 25
  • 37
user3529582
  • 165
  • 2
  • 11

2 Answers2

3

You never initialize gesto, so you probably get a NullPointerException when you attempt to call reconocer.

Change

GestoPistola gesto;

to

GestoPistola gesto = new GestoPistola ();
Eran
  • 387,369
  • 54
  • 702
  • 768
2

You never initialize your gesto variable, so there's a NullPointerException.

Change GestoPistola gesto; to GestoPistola gesto = new GestoPistola();

Stultuske
  • 9,296
  • 1
  • 25
  • 37