멀티터치를 구현하고자 합니다.

예전에

간단하게 쓰자면
x1 = (int)event.getX(0);
x2 = (int)event.getY(1);
action = event.getAction();

이런식으로 구현을 하고

action을 통해 현재 업, 다운, 무브를 멀티를 판단하고 했는데

멀티터치 중에 여러 액션을 할 경우 제대로 반영이 안되더라구요.


인터넷으로 찾아보니

int actionPointerId = action & MotionEvent.ACTION_MASK;
   int actionEvent = action & MotionEvent.ACTION_MASK;
   int pointerIndex = event.findPointerIndex(actionPointerId);

   xPos = (int)event.getX(pointerIndex);
   yPos = (int)event.getY(pointerIndex);

이런류로 멀티터치를 구현한 것이 있던데

전 각각의 좌표를 따로 갖고싶어서

int X[] = new int[2];
int Y[] = new int[2];

   X[pointerIndex] = (int)event.getX(pointerIndex);
     Y[pointerIndex] = (int)event.getY(pointerIndex);

이런식으로 넣었는데

에러가 나네요,
(배열의 수를 늘려도 에러가 납니다.
java.lang.ArrayIndexOutOfBoundsException
at android.view.MotionEvent.getX(MotionEvent.java.733)

X[pointerIndex] = (int)event.getX(pointerIndex);
포인터 인덱스 값이 문제인거 같은데 잘모르겠네요.


멀티터치의 값을 각각의 변수로 따로 관리 하려면 어떻게 해야 하나요?