0

I am writing an activity where there is a picture that is hidden by some other picture that is broken to active slices. You will be able to click each slice and perform some action. When this action is successfull the overlay slice disappears and a part of original image is displayed. The game finishes when you uncover complete image.

enter image description here

Imagine Mahjongg with the floor level. You can click a tile and if it matches another selected tile the background under the tile is displayed. My task is similar. I want to hide the picture with series of tiles that user can click.

enter image description here

I already started with some investigation. Interesting concept was explained a ImageMap blog. That could work but I would love to generate number of tiles dynamically - based on a display resolution and a difficulty level.

I tend to implement the logic manually using custom View with Canvas that holds uncovered tiles graphics and when I need to unhide target image slice I will get it from the target Bitmap. Seems like a lot of calculations.

Is there a better way?

Leos Literak
  • 8,805
  • 19
  • 81
  • 156
  • a custom view is an east way of detecting the taps on the view but the prize is many custom View objects, why do you think it is not a proper way? – pskink Oct 18 '15 at 13:00
  • I wonder if there is an easier way. For example to have RelativeLayout with two ImageViews and once each tile is solved make the tile transparent .. – Leos Literak Oct 18 '15 at 13:04
  • i would use a custom View with a custom parent ViewGroup as a layout that layouts its children in a grid like form – pskink Oct 18 '15 at 13:07
  • What will be its children? Tiles as ImageButton? How will the target image be displayed? – Leos Literak Oct 18 '15 at 13:12
  • 1
    parent: custom ViewGroup that display the background by using `android:background` or overriding `dispatchDraw / draw / onDraw`, child : custom View that draws a puzzle tile – pskink Oct 18 '15 at 13:18
  • Thank you @pskink. I succeeded with hard coded values. But I am stuck with passing current resource from activity: http://stackoverflow.com/questions/33460078/passing-resource-id-from-activity-to-initialize-custom-viewgroup Can you look at it please? – Leos Literak Nov 01 '15 at 07:22

0 Answers0