Problemas de puntero! (Androide)
Tengo un problema con varios punteros en un método onTouch. Todos los punteros están asociados con un valor booleano, verdadero si está abajo y falso si está arriba. Es muy importante que si un puntero cambia de verdadero a falso, no afectará a los otros valores booleanos.
El problema que tengo es cuando, por ejemplo, el puntero 1 y 2 están abajo y el puntero 2 sube (cambia a falso), el puntero 1 también está en esa iteración cambiada a falso. Esto se debe a que los identificadores de punteros están cambiando cuando cambia el número de punteros.
¿Tiene alguna sugerencia de cómo solucionar los problemas que estoy teniendo?
Este es el código:
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int action = (event.getAction() & MotionEvent.ACTION_MASK);
int pointCount = event.getPointerCount();
for (int i = 0; i < pointCount; i++) {
int id = event.getPointerId(i);
if (id < MAX_NUMBER_OF_POINT) {
Log.d(TAG, String.valueOf(id));
xA[id] = (int) event.getX(i);
yA[id] = (int) event.getY(i);
if ((action == MotionEvent.ACTION_DOWN)
|| (action == MotionEvent.ACTION_POINTER_DOWN)
|| (action == MotionEvent.ACTION_MOVE)) {
touching[id] = true;
} else {
Log.e(TAG, "i: " + String.valueOf(i));
Log.e(TAG, "id: " + String.valueOf(id));
touching[id] = false;
}
}
}
for (int i2 = 0; i2 < 5; i2++) {
if (touching[i2] == false) {
// Log.d(TAG, "Was Here" + String.valueOf(i2));
xA[i2] = 0;
yA[i2] = 0;
}
}
x1 = xA[0];
x2 = xA[1];
x3 = xA[2];
x4 = xA[3];
y1 = yA[0];
y2 = yA[1];
y3 = yA[2];
y4 = yA[3];
return true;
}
¡Gracias!