Game Development Reference
In-Depth Information
id[i]=pointerId;
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[i]=( int ) (event.getX(i) * scaleX);
touchEvent.y=touchY[i]=( int ) (event.getY(i) * scaleY);
isTouched[i]= false ;
id[i]=-1;
touchEventsBuffer.add(touchEvent);
break ;
case MotionEvent. ACTION_MOVE :
touchEvent=touchEventPool.newObject();
touchEvent.type=TouchEvent. TOUCH_DRAGGED ;
touchEvent.pointer=pointerId;
touchEvent.x=touchX[i]=( int ) (event.getX(i) * scaleX);
touchEvent.y=touchY[i]=( int ) (event.getY(i) * scaleY);
isTouched[i]= true ;
id[i]=pointerId;
touchEventsBuffer.add(touchEvent);
break ;
}
}
return true ;
}
}
public boolean isTouchDown( int pointer) {
synchronized ( this ) {
int index=getIndex(pointer);
if (index<0 || index >= MAX_TOUCHPOINTS )
return false ;
else
return isTouched[index];
}
}
public int getTouchX( int pointer) {
synchronized ( this ) {
int index=getIndex(pointer);
if (index<0 || index >= MAX_TOUCHPOINTS )
return 0;
else
return touchX[index];
}
}
Search WWH ::




Custom Search