2012-07-04 4 views
0

몇 가지 오류 받기 및 무엇을 해야할지 모릅니다. 도와주세요. 안드로이드 버전 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; 
    } 
} 
+0

여기에 무엇을하려고합니까? touchEvent.x = touchX [pointerId] = (int) (이벤트 .getX (pointerIndex) * scaleX); ??? 위와 같아야합니다. touchEvent.x = touchX [pointerId] = (int) (이벤트 .getX() * scaleX); –

+0

나는 TouchEvent 인스턴스에 대한 풀을 만들고 OnTouchListener로 핸들러를 등록하고 스크롤 값을 저장한다. –

답변

0

오류가 발생하는 모든 mthod는 선택한 API 레벨에서 사용할 수 없습니다. API 레벨을 높이거나 멀티 터치 전용 코드를 제거하십시오.

+0

내 문제를 해결하는 것 같다. –

+0

듣고있어 기쁘다. :) – Magicode

0

당신의 방법/변수는 그것의 외모를 사용하고있는 문맥에 필요한 유형까지 일치하지 않습니다.

코드를 살펴보고 인수 및 반환 유형이 모두 일치하는지 확인하십시오.

+0

모두가 일치하는지 확인한다. –

관련 문제