ClippingNode to mask

Hi!

I’m trying to figure out how to use the ClippingNode but I’m quite lost, I have read the other replies, but I didn’t it to work properly. It removed the transparency I had in the image already aswell.

So I have an image with transparency, let’s call it Plank.
Then I want to mask out in the plank a Circle (which is a CCSprite) and also a Rectangle (which is also a CCSprite). How would I do this?

1 Like

There is a nice example cocos2d-x\tests\cpp-tests\Classes\ClippingNodeTest. Check it out. Specifically, HoleDemo. That’s what you need.

I copied the code used in the hole test and tried it in my own project.
Why does the clipping node turn my whole screen into white?

This guy probably has the same problem: http://stackoverflow.com/questions/24867486/cocos2d-x-v3-clippingnode-not-working-on-rendertexture

Found the error… It seems current version (release version of cocos2d-x 3.2) has a bug with the clippingnode in android causing the whole screen to turn to white.

You can read about how to fix it here:

So basically, all I did was edit
cocos2d-x-3.2\projects\myGame\proj.android\src\org\cocos2dx\cpp\AppActivity.java

so it says:
package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;

public class AppActivity extends Cocos2dxActivity {
@Override
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); // this line is required for clipping

    return glSurfaceView;
}

}

1 Like

Nice, this fixed the same issue for me on version 3.2. Thanks!

thank you a lot, this saved my issue with using cab files with android :smile: