몇 가지 오류 받기 및 무엇을 해야할지 모릅니다. 도와주세요. 안드로이드 버전 1.5에서 뱀 게임을 개발하고 이클립스 SDK 버전 4.2.0을 사용하는 것은 이러한 오류가 내 게임을 디버그 할 수 없도록하는 유일한 방법 인 것처럼 보입니다.MultiTouchHandler 몇 가지 오류가 있습니까?
The method getX() in the type MotionEvent is not applicable for the arguments (int)
The method getY() in the type MotionEvent is not applicable for the arguments (int)
The method getX() in the type MotionEvent is not applicable for the arguments (int)
The method getY() in the type MotionEvent is not applicable for the arguments (int)
The method getPointerCount() is undefined for the type MotionEvent
The method getPointerId(int) is undefined for the type MotionEvent
ACTION_POINTER_DOWN cannot be resolved or is not a field
The method getX() in the type MotionEvent is not applicable for the arguments (int)
The method getY() in the type MotionEvent is not applicable for the arguments (int)
ACTION_POINTER_UP cannot be resolved or is not a field MultiTouchHandler.java
ACTION_MASK cannot be resolved or is not a field
ACTION_POINTER_ID_MASK cannot be resolved or is not a field
ACTION_POINTER_ID_SHIFT cannot be resolved or is not a field
The method getPointerId(int) is undefined for the type MotionEvent
코드 :
public boolean onTouch(View v, MotionEvent event) {
synchronized (this) {
int action = event.getAction() & MotionEvent.ACTION_MASK;
int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
int pointerId = event.getPointerId(pointerIndex);
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
touchEvent = touchEventPool.newObject();
touchEvent.type = TouchEvent.TOUCH_DOWN;
touchEvent.pointer = pointerId;
touchEvent.x = touchX[pointerId] = (int) (event
.getX(pointerIndex) * scaleX);
touchEvent.y = touchY[pointerId] = (int) (event
.getY(pointerIndex) * scaleY);
isTouched[pointerId] = true;
touchEventsBuffer.add(touchEvent);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
case MotionEvent.ACTION_CANCEL:
touchEvent = touchEventPool.newObject();
touchEvent.type = TouchEvent.TOUCH_UP;
touchEvent.pointer = pointerId;
touchEvent.x = touchX[pointerId] = (int) (event
.getX(pointerIndex) * scaleX);
touchEvent.y = touchY[pointerId] = (int) (event
.getY(pointerIndex) * scaleY);
isTouched[pointerId] = false;
touchEventsBuffer.add(touchEvent);
break;
case MotionEvent.ACTION_MOVE:
int pointerCount = event.getPointerCount();
for (int i = 0; i < pointerCount; i++) {
pointerIndex = i;
pointerId = event.getPointerId(pointerIndex);
touchEvent = touchEventPool.newObject();
touchEvent.type = TouchEvent.TOUCH_DRAGGED;
touchEvent.pointer = pointerId;
touchEvent.x = touchX[pointerId] = (int) (event
.getX(pointerIndex) * scaleX);
touchEvent.y = touchY[pointerId] = (int) (event
.getY(pointerIndex) * scaleY);
touchEventsBuffer.add(touchEvent);
}
break;
}
return true;
}
}
여기에 무엇을하려고합니까? touchEvent.x = touchX [pointerId] = (int) (이벤트 .getX (pointerIndex) * scaleX); ??? 위와 같아야합니다. touchEvent.x = touchX [pointerId] = (int) (이벤트 .getX() * scaleX); –
나는 TouchEvent 인스턴스에 대한 풀을 만들고 OnTouchListener로 핸들러를 등록하고 스크롤 값을 저장한다. –