I am coding a tetris like game and am wondering if there is an easier way to track clicks.
The game board is a 6 by 8 grid of rectangles. I have a class GameBoard
that extends View
. Here I override the onDraw(Canvas canvas)
method and draw the board via a bunch of canvas.drawRect(30,30,80,80,paint)
calls.
Is there an easy way to hook up a handler to tell me which rectangle has been clicked? In .net you can use rect.contains(Point p).
Or am I just stuck doing the mat to figure out what rectangle a given point is in?