此问题我的原文和解决办法:
http://stackoverflow.com/questions/28367881/why-i-need-add-empty-ccclippingnode-between-each-slice-part-in-cocos2dx-2-2-6/28367882#28367882
帮助贴:
http://blog.csdn.net/jusnxie/article/details/9277121
起先我发现切割图片的贴图错误了,但是找不到问题在哪. 于是我自己来回测试,发现每隔一个CCClippingNode创建一个空的CCClippingNode就不会出现这个问题,于是我发现了是openGL缓存的问题,
另外stencil深度需要开启,cpp项目在AppController.mm中,默认新版模板是开启的,老版模板是关闭的,所以我发现我的demo能运行,而老游戏不支持:
改为
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] pixelFormat: kEAGLColorFormatRGB565 depthFormat: GL_DEPTH24_STENCIL8_OES preserveBackbuffer: NO sharegroup: nil multiSampling: NO numberOfSamples:0 ];
- glStencilFunc(GL_NEVER,mask_layer,mask_layer);
- glClearStencil(!m_bInverted?0:~0);
- glStencilOp(!m_bInverted?GL_ZERO:GL_REPLACE,GL_KEEP,GL_KEEP);
- @H_502_74@//drawafullscreensolidrectangletoclearthestencilbuffer
- //ccDrawSolidRect(CCPointZero,ccpFromSize([[CCDirectorsharedDirector]winSize]),ccc4f(1,1,1));
- ccDrawSolidRect(CCPointZero,ccpFromSize(CCDirector::sharedDirector()->getWinSize()),1));
- glClear(GL_STENCIL_BUFFER_BIT);