简体   繁体   English

如何使CCRenderTexture透明

[英]how to make CCRenderTexture transparent

i'm trying to make CCRenderTexture's empty parts transparent instead of black in Cocoss2d-x. 我正在尝试使CCRenderTexture的空白部分透明,而不是Cocoss2d-x中的黑色。 Is there any solution? 有什么解决办法吗?

Here's my code 这是我的代码

cocos2d::CCPoint screenMid = ccp(size.width * 0.5f, size.height * 0.5f);

CCRenderTexture * masked = CCRenderTexture::create(size.width, size.height);    
masked->getSprite()->setBlendFunc((ccBlendFunc) { GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA });
masked->setPosition(screenMid);
this->addChild(masked);

Normally there should be a "clear" function that you call before drawing anything onto the render texture. 通常,在将任何内容绘制到渲染纹理上之前,应该调用一个“清除”函数。 At least in cocos2d-iphone version there's one. 至少在cocos2d-iphone版本中有一个。

If you set the clear color to use 0.0 alpha then that'll make the render texture fully transparent initally. 如果将清除颜色设置为使用0.0 alpha,则将使渲染纹理最初完全透明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM