//Opacity 0完全透明 255完全不透明 //ALPHA 0完全透明 1完全不透明 CCRenderTexture* pRT = CCRenderTexture::create(480,320); pRT->setPosition(Point(480,320)); addChild(pRT,1); CCSprite* pSpr1 = CCSprite::create("1.png"); pSpr1->setAnchorPoint(CCPoint::ZERO); ccBlendFunc blend; blend.src = GL_ONE; blend.dst = GL_ZERO; pSpr1->setBlendFunc(blend); CCSprite* pSpr2 = CCSprite::create("HelloWorld.png"); pSpr2->setPosition(ccp(0,0)); pSpr2->setAnchorPoint(CCPoint::ZERO); ccBlendFunc blend1; blend1.src = GL_DST_ALPHA;//GL_ONE_MINUS_DST_ALPHA //GL_ONE blend1.dst = GL_ZERO;//GL_ONE_MINUS_SRC_ALPHA; pSpr2->setBlendFunc(blend1); pRT->clear(1,0,0,0); pRT->begin(); pSpr1->visit(); pSpr2->visit(); pRT->end();
效果就是第2张图片和第1张图片重叠的地方由第1张图片的alpha值来决定