The app is following. I have a line at the screen. I touch the screen and move finger. At the moment when my finger touches this line - I want to show a message at the moment of intersection.
The code:
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction() ;
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
boolean isline = check_line(event.getX(),event.getY());
if(isline){
//SHOW MESSAGE
}
break;
case MotionEvent.ACTION_UP:
break;
}
return true;
}
But the app sometimes can't catch the moment when when the finger is on the line. If I move slowly - then the message always appears. But if I move a bit faster - no messages.
The equation of the line is A*x + B*y + C = 0
check_line is a mathematical function, which just places my x and y in this equation. So when the equation is satisfied it returnes true, otherwise - false.
But I want all the cases to be catched.
What to do?