1

I'm trying to make a game that will have a black screen, when you swipe the screen, the black portion you touch will disappear and show a image behind it. The object is to keeping swiping until you can guess what the image is.

I have seen other apps that do this. I'm stuck on how to do it. My idear was to modify a bitmap by changing the pixcels to see through. But I don't see any way of getting access to the bitmaps memory, or maybe there is another way to do this????

Ted pottel
  • 6,869
  • 21
  • 75
  • 134
  • For a straightforward example of something similar to what the answers show, try http://stackoverflow.com/a/8331747/752320 – Geobits Oct 20 '12 at 00:47

3 Answers3

2

One way to make this would be having your bitmap drawn like any other image, and on top of it you'll have an editable black bitmap (that you can dinamically make using draw(), look for documentation on Paint class), and when the user swipes, you record the path, and use a brush to paint transparent pixels on the black bitmap, so the image below will become visible.

That last part is almost the same as implementing a simple paint app, so it shouldn't be hard to figure out.

Rodrigo Castro
  • 1,573
  • 14
  • 38
1

A potential solution is to create a copy of the image bitmap using the copy method. This way you can make modifications to the image.

Then mask the image with the black square. As the user wipes their finger over the image you need to record the path they follow and create a masking image based from this. Using that mask you can go through your original image and black out the image only in the areas that the path of swipes does not cover.

It would probably be worth checking out the Paint class.

marcus.ramsden
  • 2,633
  • 1
  • 22
  • 33
0

you could use a ViewPager, but i suspect that's not the type of swipe effect you want. it's be an easy way implement however. ViewPager is used extensively in the stock android apps. take a look at how Play Music lets you swipe between recent / albums / ... views. as you can see it's more of a paging (vs. swiping) effect.

you could use ImageSwitcher, and add animations for the in / out effect. here's a SO article that talks about how to use it with animations,

Setting animation ImageSwitcher will run (in_left or out_right)

this doesn't work great however, because the animation is triggered after the swipe is detected ... the animation doesn't follow the swipe.

if you don't like these, you are probably stuck with writing some OpenGL code to get what you want.

Community
  • 1
  • 1
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
  • You can make a mutable copy of a bitmap allowing you to draw in custom items. The problem is this can eat a fair amount of memory, if you are running short of disk space then try saving the image to disk then reading it back into a mutable bitmap instance using the method outlined here, http://stackoverflow.com/a/9194259/425519. – marcus.ramsden Oct 20 '12 at 00:10