I'm building a touch game where you have to touch the inside of an image that was drawn on a canvas. The image gets drawn at new positions every few secs anyways the issue is detecting a touch inside the image. The below is my touch event and it does work however it only detects the touch if you touch the top of the image but anywhere else it fails to
synchronized public boolean onTouchEvent(MotionEvent event){
boolean handled = false;
int action = event.getAction();
int x = (int) event.getRawX(); //or event.getRawX();
int y = (int) event.getRawY();
switch (action){
case MotionEvent.ACTION_DOWN:
touchDownTime = SystemClock.elapsedRealtime();
break;
case MotionEvent.ACTION_UP:
if ( x >= bonX && x < bonX + ((GameWorld)findViewById(R.id.game_canvas)).joviWidth()
&& y >= bonY && y < bonY + ((GameWorld)findViewById(R.id.game_canvas)).joviHeight() ) {
Log.d("TOuched",x+","+y);
}
handled = true;
break;
}
return handled;
}
how you guys will be able to provide some help thank you
Edit: Just notice I may of posted this in the wrong area i'm sorry if i did