Cocos2dx3.2 Crazy Tetris 由于遮罩引起的部分手机白屏

来源:互联网 发布:js时间选择插件 编辑:程序博客网 时间:2024/05/01 04:48

上一章是说明使用ClipplingNode制作遮罩,以显示不规则图形。但是这样一直到Android端,却在部分手机中发生了问题。

具体问题表现为:白屏,只有边界(右上角)有矩形色块。

这里其实是框架对Android手机引用OennGL时,设置上没有启用stencil buff的问题。

解决方案,在onCreateView构造函数中添加:

Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);


打开Cocos2dxGLSurfaceView的实现,发现其中并没有setEGLConfigChooser函数,而Cocos2dxGLSurfaceView继承自GLSurfaceView。查询了一下GLSurfaceView,发现有API

void setEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)//Install a config chooser which will choose a config with at least the specified component sizes, and as close to the specified component sizes as possible.

这里可以看到,最后一个参数就是对stencil的设置,而在Cocos2dxActivity的内部初始化中,我们可以看到,其设置是:

if (isAndroidEmulator())   this.mGLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0);

关于制作游戏相关其他博客的目录,我放在利用Cocos2dx3.2制作重力版俄罗斯方块(Crazy Tetris)


0 0
原创粉丝点击