How to use CCClippingNode?

Hi, I’m using cocos2d-x, and I want to clip a node (with many sprites). When the layer, parent of the node, zooming, the clip bounds must correct. So, I need to use CCClippingNode, but it not clip my node. How to do that? Anyone help me! Thanks

1 Like

Did you activate STENCIL?

Fedor Shubin wrote:

Did you activate STENCIL?

I came across the same problem.
How to activate STENCIL?

for iOS:
in AppController replace the gl-view creation with:

    EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
                                     pixelFormat: kEAGLColorFormatRGBA8
                                     depthFormat: GL_DEPTH24_STENCIL8_OES
                              preserveBackbuffer: NO
                                      sharegroup: nil
                                   multiSampling: NO
                                 numberOfSamples: 0];

for Android:
in game activity:

    public Cocos2dxGLSurfaceView onCreateView() {
        Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
        glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
        return glSurfaceView;
    }

Long Tran Si wrote:

Hi, I’m using cocos2d-x, and I want to clip a node (with many sprites). When the layer, parent of the node, zooming, the clip bounds must correct. So, I need to use CCClippingNode, but it not clip my node. How to do that? Anyone help me! Thanks

There are examples in 2.1 testcpp

thank you for Fedor Shubin

@vedi It is ok, but the listview doesnot work good.
if I add “Cocos2dxGLSurfaceView onCreateView()” in game activity.

ERROR:
FATAL EXCEPTION: main
java.lang.Error: Unresolved compilation problems:
Cocos2dxGLSurfaceView cannot be resolved to a type

wpa_supplicant
wlan0: Failed to initiate AP scan

how to solve this problem,please?

@vedi if I change it in the libcocos2dx Cocos2dxActivity:

    //  this.mGLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0);  
    this.mGLSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); 

it works ,but the listview is not ok still.