I have an image view that I draw my game board in for my game. I need to get the X, Y of the touch relative to the image view. For example: If someone touched the very top left Pixel, it would return (0,0) or, say the game board was a 100,100 board, and I touched right in the middle I would get (50,50)...How would one do this?
gameView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
int x = (int) event.getX() / pieceSize;
int y = (int) event.getY() / pieceSize;
Log.d("Touch Event", "Touch event at "+ x + " " +y);
doMove(x, y);
Log.d("Move", "The move was " + doMove(x,y));
}
gameView.setImageBitmap(Draw(pieceSize));
return true;
}
});