2013-06-18 2 views
2

나는 Processing을 처음 사용하며 안드로이드 모드로 스케치를 실행하고 싶습니다. 나는 그것이 동시에 여러 접촉을 지원하기를 원한다.처리가 멀티 터치를 처리 할 수 ​​있습니까?

가 어떻게 내 스케치 지원 여러 접촉을 할 수 있습니다 : 누군가가이 질문에 나를 인도 할 수있는 경우

궁금 해서요?

+0

http://tillnagel.com/ 2011/06/simpletouch-multitouch-library-for-processing /)하지만 2011 년부터 업데이트되었는지는 모르겠습니다. – user2468700

+0

여기를보십시오 : http://www.tuio.org/?software –

답변

6

에서 처리 안드로이드 위키에 대한 몇 가지 링크가 여기에 전체 예는 다음과 같습니다

나는 [처리를위한 멀티 터치 라이브러리를 (발견
/* 
* 
* androidMultiTouch.pde 
* Shows the basic use of MultiTouch Events 
* 
*/ 

//----------------------------------------------------------------------------------------- 
// IMPORTS 

import android.view.MotionEvent; 


//----------------------------------------------------------------------------------------- 
// VARIABLES 

int TouchEvents; 
float xTouch[]; 
float yTouch[]; 
int currentPointerId = 0; 
boolean printFPS; 


//----------------------------------------------------------------------------------------- 

void setup() { 
    size(displayWidth, displayHeight); 
    orientation(LANDSCAPE); 
    background(0, 255, 0); 
    fill(0, 0, 244); 
    rect(100, 100, 100, 100); 
    stroke(255); 

    // Initialize Multitouch x y arrays 
    xTouch = new float [10]; 
    yTouch = new float [10]; // Don't use more than ten fingers! 

} 

//----------------------------------------------------------------------------------------- 

void draw() { 
    background(255, 0, 0); 

    for (int i = 0; i < xTouch.length; i++) { 
    ellipse(xTouch[i], yTouch[i], 150, 150); 
    } 

} 

//----------------------------------------------------------------------------------------- 

public boolean surfaceTouchEvent(MotionEvent event) { 

    // Number of places on the screen being touched: 
    TouchEvents = event.getPointerCount(); 

    // If no action is happening, listen for new events else 
    for (int i = 0; i < TouchEvents; i++) { 
    int pointerId = event.getPointerId(i); 
    xTouch[pointerId] = event.getX(i); 
    yTouch[pointerId] = event.getY(i); 
    float siz = event.getSize(i); 
    } 

    // ACTION_DOWN 
    if (event.getActionMasked() == 0) { 
    print("Initial action detected. (ACTION_DOWN)"); 
    print("Action index: " +str(event.getActionIndex())); 
    } 
    // ACTION_UP 
    else if (event.getActionMasked() == 1) { 
    print("ACTION_UP"); 
    print("Action index: " +str(event.getActionIndex())); 
    } 
    // ACTION_POINTER_DOWN 
    else if (event.getActionMasked() == 5) { 
    print("Secondary pointer detected: ACTION_POINTER_DOWN"); 
    print("Action index: " +str(event.getActionIndex())); 
    } 
    // ACTION_POINTER_UP 
    else if (event.getActionMasked() == 6) { 
    print("ACTION_POINTER_UP"); 
    print("Action index: " +str(event.getActionIndex())); 
    } 
    // 
    else if (event.getActionMasked() == 4) { 

    } 

    // If you want the variables for motionX/motionY, mouseX/mouseY etc. 
    // to work properly, you'll need to call super.surfaceTouchEvent(). 
    return super.surfaceTouchEvent(event); 
} 
1
+0

글쎄, 또한, 내 스케치는 JavaScript 모드에서 실행되지 않습니다. (Dunno. 왜 최신 JRE와 JDK가 있습니까? –

+0

좋아,하지만 그게 reall입니다. y 별도의 질문입니다. 자바 스크립트 모드에서 실행되지 않는 이유는 많이 있습니다. 단서를 제공하지 않은 경우 ... –

관련 문제