Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My game involves "wiping off" an image by touch:

before wipe

After moving a finger over it, it looks like this:

after wipe

At the moment, I'm implementing it with Canvas, like this:

9Paint pTouch;
9int X = 100;
9int Y = 100;
9Bitmap overlay;
9Canvas c2;
9Rect dest;

    pTouch = new Paint(Paint.ANTI_ALIAS_FLAG);         
    pTouch.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT)); 
    pTouch.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL));

    overlay = BitmapFactory.decodeResource(getResources(),R.drawable.wraith_spell).copy(Config.ARGB_8888, true); 

    c2 = new Canvas(overlay);

    dest = new Rect(0, 0, getWidth(), getHeight());
    Paint paint = new Paint();9       


    protected void onDraw(Canvas canvas) {

        c2.drawCircle(X, Y, 80, pTouch);
        canvas.drawBitmap(overlay, 0, 0, null);


9public boolean onTouchEvent(MotionEvent event) {

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE: {
                X = (int) event.getX();
                Y = (int) event.getY();9 
                c2.drawCircle(X, Y, 80, pTouch);9               
return true;

What I'm essentially doing is drawing transparency onto the canvas, over the red ball image.

Canvas and Bitmap feel old... Surely there is a way to do something similar with OpenGL ES. What is it called? How do I use it?


I found that if I draw an image and above new image with alpha 0, it goes to be transparent, maybe that direction?

Something like:

gl.glColor4f(0.0f, 0.0f, 0.0f, 0.01f);
share|improve this question
Really interesting who did down vote and why. If you don't know answer, don't vote at all –  Maxim Shoustin Jul 24 '13 at 21:14
I agree, unexplained downvotes are unhelpful. The question is still quite unclear though: What exactly do you want? (What counts as the touched area? Do you want the image to be painted black or clipped to transparent?) What have you tried? (Do you know any OpenGL ES?) Why is what you tried not working? –  Anko Jul 25 '13 at 9:07
Ok, maybe black color is bit confused. Actually the background is transparent. Lets say BG is green. So I see red button on green BG. when i move finger over button (its image) i draw in my example transparent view that make effect like "Erase" part of red button. Take a look on my example, onTouchEvent I draw transparent circles. –  Maxim Shoustin Jul 25 '13 at 9:19
OK, so you're drawing a bitmap with an arbitrary clipping shape. And you want to port it to OpenGL ES. Again: What have you tried and why is it not working? –  Anko Jul 25 '13 at 9:50
Maybe you should start by learning OpenGL ES? GameDev SE isn't good for "how do I get started"-questions. The Wikibooks article on OpenGL stencils looks like a good place to start though! –  Anko Jul 25 '13 at 10:05

1 Answer 1

There are many ways to go about doing this I suppose in openGL.

  • First, you could make a sprite sheet of every step of the covering of the ball and by using


on the

  • Second, and probably better you could make a second black ball texture that moves over it with the persons figure in your Render loop.

    glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

  • You could use geometry to do it.

  • You can also do it in canvas like this with the same idea as number 2:


share|improve this answer
actually, its only demo (black screen), my background is camera view. Link you posted refers to canvas but not to OpenGL ES –  Maxim Shoustin Jul 30 '13 at 18:25
javacodegeeks.com/2011/09/… –  Justin Jul 30 '13 at 18:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.