I'm writing normal jigsaw puzzle game. For convenience I've created a custom view: PuzzleView extends ImageView
. It overiddes onTouchEvent()
, so I can move my View
with a finger. Nice.
However, I have a problem with putting these Views close to each other, so they fit in themselves. Puzzles are not squares, their shape look like this:
And the problem is that these views must overlap a little bit to look good. But when squares overlap, touch events works bad in the intersection area. If I naively put that puzzle as a background of PuzzleView
, 4 of them will look like this:
They have transparency, so I could squeeze them to look good. But it's not a good idea, because of the touch events. If we touch in the border, the puzzle which is "higher" (in z-index) will be touched. And maybe user wants to pick up the other one and he can't.
I've read a bit about Android'sShape
class. It would be great if I have a Shape
of a puzzle - then I can use it as a background of my PuzzleView
and I hope that MotionEvent
will only come when I touch the shape, not some rectangular area around it.
The question is: how to get a Shape
of a puzzle? Ideally, I will point my image and it will give me a Shape
taken from that image. If it's not possible (or very hard) maybe we can somehow make this puzzleShape
with Path
, but how to do it? Maybe it is too complicated shape to use Path
? Maybe there is an easier way?