cocos2dx 3.x判断node点击区域是否透明

有时候我们需要判断自己所触摸的区域是否是透明的,这时就需要调用glReadPixels函数来进行rgb色值的提取了

白白原创,,手游专栏

Size size = Director::getInstance()->getVisibleSize();CCRenderTexture* render = RenderTexture::create(size.width, size.height);render->beginWithClear(0,0,0,0);node->visit(); //白白原创GLubyte pColor[4];Point location = this ->convertTouchToNodeSpace(touch); glReadPixels(location.x,location.y,1,1,GL_RGBA,GL_UNSIGNED_BYTE,&pColor[0]);render->end();log("r %d g %d b %d a %d", pColor[0],pColor[1],pColor[2],pColor[3]);if (!pColor[0]&&!pColor[1]&&!pColor[2]){log("tou ming");}else{log("bu tou ming");}

敏而好学,不耻下问。

cocos2dx 3.x判断node点击区域是否透明

相关文章:

你感兴趣的文章:

标签云: