- 本帖最后由 kcl_70 于 2013-3-22 14:19 编辑 *
//将点击点转换成自己坐标系中的坐标,相对于0,0点 CCPoint pt = convertTouchToNodeSpace(touch); int nw = getContentSize().width; int nh = getContentSize().height;
CCRect rc(0, 0, nw, nh); if(rc.containsPoint(pt)) { //获得点击的OpenGL的世界坐标值 CCPoint touchPoint = touch->getLocation(); //检测矩形区域 CCPoint location = ccp(touchPoint.x * CC_CONTENT_SCALE_FACTOR(), touchPoint.y * CC_CONTENT_SCALE_FACTOR());
UInt8 data;
CCRenderTexture* renderTexture = CCRenderTexture::create(this->boundingBox().size.width* CC_CONTENT_SCALE_FACTOR(), this->boundingBox().size.height * CC_CONTENT_SCALE_FACTOR(), kCCTexture2DPixelFormat_RGBA8888);
renderTexture->begin(); this->visit();
glReadPixels((GLint)location.x,(GLint)location.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data);
renderTexture->end(); renderTexture->release();
NSLog(@“X:.0f y:.0f R: %d, G: %d, B: %d, A: %d tag:%d”,location.x ,location.y, data, data, data, data,this->getTag());
if(data != 0 && data != 0 && data != 0 && data != 0) { this->setBlendFunc((ccBlendFunc) {GL_ONE, GL_ONE}); return true; } } return false;如题,怎么样可以精确的判断是否点击某一Sprite的透明区域