2016-06-02 9 views
1

나는 LibGDX로 게임을 개발 중이고 pan에서 fling을 결정하는 데 문제가 있습니다. 내 GestureListenerlibgdx에서 냄비에서 새끼 손가락 결정

:

@Override 
public boolean fling(float velocityX, float velocityY, int button) { 
    //if (velocityX > 1000f) { 
    // I can use this to exclude slow pans from the executing a fling 
     System.out.println("Flinged - velocityX: " + velocityX + ", button: " + button); 
    //} 
    return false; 
} 

@Override 
public boolean pan(float x, float y, float deltaX, float deltaY) { 
    // but there doesn't seem to be a way to have this not fire on a fling 
    System.out.println("Panned - deltaX: " + deltaX); 
    return false; 
} 

@Override 
public boolean panStop(float x, float y, int pointer, int button) { 
    System.out.println("Pan Stop - pointer: " + pointer + ", button: " + button); 
    return false; 
} 

문제는 pan 두 경우와 fling 화재입니다. fling은 기본적으로 빠른 pan이지만 두 가지 동작을 결정할 수 있어야 각 상황을 개별적으로 처리 할 수 ​​있습니다.

간결한 묻는 방법은 flingpan에 대해 고유 한 작업을 어떻게 제공합니까?

답변

0

내 의견으로는 이에 대한 가장 합리적인 해결책은 길게 누르면없이 강타하는 것은 단지 날뛰는를 만드는 방법에 대한 것입니다 때 '패닝 모드로 들어가'일부 부울 플래그를 설정하는 longPress을 사용하는 것입니다.

물론
//the flag for checking if pan mode entered 
    boolean PAN = false; 

    @Override 
    public boolean longPress(float x, float y) { 
     PAN = true; 
     return false; 
    } 

    @Override 
    public boolean fling(float velocityX, float velocityY, int button) { 
     if(!PAN) { 
      System.out.println("Flinged - velocityX: " + velocityX + ", button: " + button); 
     } 
     return false; 
    } 

    @Override 
    public boolean pan(float x, float y, float deltaX, float deltaY) { 
     if(PAN) { 
      System.out.println("Panned - deltaX: " + deltaX); 
     } 
     return false; 
    } 

    @Override 
    public boolean panStop(float x, float y, int pointer, int button) { 
     if(PAN) { 
      PAN = false; 
      System.out.println("Pan Stop - pointer: " + pointer + ", button: " + button); 
     } 
     return false; 
    } 

longPress 당신이

+0

기술적으로 작동 이쪽 GestureDetector 인스턴스의 setLongPressSeconds(float longPressSeconds) 방법을 사용하여 변경할 수 있습니다 당신의 목적을 위해 너무 긴 경우,하지만 것 같다

이 내가이 참조하는 방법입니다 "느낌"을 얻는 것이 불가능합니다. 나는 팬과 플링 사이를 감지 할 수 있지만, 지금은 오랫동안 언론의 관심을 가지고 놀고 있었고, 이것이 제대로 작동하려면 좋은 숫자를 얻는 것이 거의 불가능한 것처럼 보입니다. 내 Nexus 5에서 테스트하는 동안 ~ 100ms (0.1 초)가 가장 효과적 이었지만 일관성이 없었습니다. 때로는 나에게 느껴지는 것 (슬쩍/튀기기보다 느린 것)이 등록되지 않았거나 때로는 그렇게되었습니다. – Townsfolk