Question

I need to develop a Instant Lottery game app.

I need an idea/procedure to implement Scratchable custom widget similar to instant Lottery Tickets in Android.

The requirement is like, the actual content(secret number) should be covered by some image(which indicates scratch area). When the user touch and scratch the image, the image has to disappear slowly and the background content(secret number) should appear accordingly.

Please let me know the best way to implement this. I am in real need of it.

Thanks in advance.

Was it helpful?

Solution

Since you don't want the entire View to change its transparency, but only the touched parts of it, you need to draw manually on the Canvas, set the PorterDuff mode on a Paint object:

mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)) 

and draw with Color.TRANSPARENT

Also see this thread in the Android developer group: http://groups.google.com/group/android-developers/browse_thread/thread/5b0a498664b17aa0/de4aab6fb7e97e38?lnk=gst&q=erase+transparent#

OTHER TIPS

Conceptually, you could put your scratch area (image) on top of the number you're initially hiding. When the user performs motions on the scratch area, change the opacity of the scratch area so it fades away with every motion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top