문제

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.

도움이 되었습니까?

해결책

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#

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top