2016-10-14 7 views
0

나는 도약 동작으로 수화 프로그램을 만들고 싶다. 팔을 뻗을 때 '수화 입력'을 의미합니다. 왼손으로 오른쪽으로 스 와이프하면 '공백'을 의미합니다. 오른손으로 왼쪽으로 스 와이프하여 '백 스페이스'를 의미합니다.스 와이프 제스처로 제스처 캐스팅

프레임에 제스처가 있는지 여부를 인식해야합니다. 프레임 수를 계산하여 계산했습니다. 맞습니까?

public void onFrame(Controller controller) { 
      Frame frame = controller.frame(); 
      String sDirection = ""; 
      GestureList gestures = frame.gestures(); 

      if (gestures.count() == 0) { 
       try{ 
        run(controller); 
       }catch(InterruptedException e){ 
        e.printStackTrace(); 
       } 

      } else { 
       sDirection = gesture(gestures); 
      } 
      System.out.println(sDirection); 

     } 

제스처, 기능 제스처 작업을 감지 할 때. 스 와이프 동작 만 필요합니다. 함수 제스처

 public String gesture(GestureList gestures) { 
       String result = ""; 
       for (int i = 0; i < gestures.count(); i++) { 

     if (gestures.get(i).type() == Gesture.Type.TYPE_SWIPE) { 

      SwipeGesture vSwipe = (SwipeGesture) gestures.get(i);///What's wrong?!!!!!!! 
      System.out.println(gestures.get(i).type()); // 
      // Compare directions and give preference to the greatest linear 
      // movement. 
      float fAbsX = Math.abs(vSwipe.direction().getX()); 
      float fAbsY = Math.abs(vSwipe.direction().getY()); 
      float fAbsZ = Math.abs(vSwipe.direction().getZ()); 

        ..... 

,

SwipeGesture vSwipe = (SwipeGesture) gestures.get (I); -> 작동하지 않았습니다.

어떻게해야합니까?

답변

0

주조는 지원되지 않습니다. Gesture 객체에서 새 SwipeGesture 객체를 만들어야합니다.

SwipeGesture vSwipe = SwipeGesture(gestures.get(i)); 
관련 문제