效果图如上。。是一个类似画笔的程序,多触控画线的时候,当一根手指up时,这个点以为是move到其他还在down的触控点。。实在是不知道怎么解决。。求大牛指点
代码如下:
public boolean onTouchEvent(MotionEvent event) {
float[] xs = new float[10];
float[] ys = new float[10];
touchPoint = event.getPointerCount();
for (int i = 0; i < touchPoint; i++) {
xs[i] =event.getX(i);
ys[i] = event.getY(i);
}
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
for (int i = 0; i < touchPoint; i++) {
lastXs[i] = xs[i];
lastYs[i] = ys[i];
showCoordinate(lastXs[i],lastYs[i]);
mPaths[i].moveTo(lastXs[i],lastYs[i]);
mCanvas.drawPoint(lastXs[i],lastYs[i],mPaints[i]);
}
break;
case MotionEvent.ACTION_POINTER_DOWN:
for (int i = 0; i < touchPoint; i++) {
lastXs[i] = xs[i];
lastYs[i] = ys[i];
showCoordinate(lastXs[i],lastYs[i]);
mPaths[i].moveTo(lastXs[i],lastYs[i]);
mCanvas.drawPoint(lastXs[i],lastYs[i],mPaints[i]);
}
break;
case MotionEvent.ACTION_MOVE:
for (int i = 0; i < touchPoint; i ++) {
int xx = (int) Math.abs(lastXs[i] - xs[i]);
int yy = (int) Math.abs(lastYs[i] - ys[i]);
if (xx > 3 || yy > 3) {
mPaths[i].lineTo(xs[i], ys[i]);
}
lastXs[i] = xs[i];
lastYs[i] = ys[i];
showCoordinate(lastXs[i],lastYs[i]);
}
break;
}
invalidate();
return true;