Hi mates,
I’m trying to clip a sprite and it works fine in browser but on android and ios it gives me this error
D/cocos2d-x debug info(29370): Stencil buffer is not enabled.
The image is not been displayed correctly, is white and not clipped.
How should I enable this from javascript?
this is my code, its located inside a ccSprite.
addTexture:function(framename){
var texturename = "texture"+this.type+".png";
var texture = cc.Sprite.create(cc.spriteFrameCache.getSpriteFrame(texturename));
this.mask = cc.Sprite.create(cc.spriteFrameCache.getSpriteFrame(framename));
var clipper = cc.ClippingNode.create();
clipper.setStencil(this.mask);
clipper.addChild(texture);
clipper.setAnchorPoint(0.5, 0.5);
clipper.setPosition(this.width/2,this.height/2);
this.addChild(clipper,1);
},
harx
#2
Maybe the following snippet can solve it.
package org.cocos2dx.js_tests;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
public class AppActivity extends Cocos2dxActivity {
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// TestCpp should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
return glSurfaceView;
}
}
This blog of mine is written about this problem perhaps help you.
Thanks mate, this removes the error line although the image is still not been clipped.
any has experience with cc.clippingnode with jsb??
@harx is correct about this, we haven’t activated stencil buffer in the project template, you can also refer to this post: Clipping issue on Android
About why you still haven’t got your sprite clipped, please check the mask you use and its size etc