本文整理汇总了C++中CCRenderTexture::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ CCRenderTexture::getParent方法的具体用法?C++ CCRenderTexture::getParent怎么用?C++ CCRenderTexture::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCRenderTexture
的用法示例。
在下文中一共展示了CCRenderTexture::getParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createStroke
//label 描边
void LabelUtils::createStroke(CCLabelTTF *label, float size, ccColor3B color)
{
CCSize originalSize = label->getTexture()->getContentSize();
float wid = originalSize.width + size * 2;
float hei = originalSize.height + size * 2;
CCPoint originalPos = label->getPosition();
CCPoint originalAnchor = label->getAnchorPoint();
ccColor3B originalColor = label->getColor();
ccBlendFunc originalBlend = label->getBlendFunc();
CCNode* node = label->getChildByTag(TAG_STROKE);
CCRenderTexture* rt = NULL;
if(node) {
rt = dynamic_cast<CCRenderTexture*>(node);
if(rt) {
// rt->clear(0, 0, 0, 0); //这里有问题,会有一个黑色块
// CCLOG("use pre-existing CCrenderTexture!");
rt->removeFromParentAndCleanup(true);
rt = NULL;
}
}
if(!rt) {
rt = CCRenderTexture::create(wid, hei);
}
label->setColor(color);
label->setBlendFunc((ccBlendFunc) {
GL_SRC_ALPHA, GL_ONE
});
// rt->setAnchorPoint(originalAnchor); //没用
CCPoint center = ccp(wid * originalAnchor.x, hei * originalAnchor.y);
rt->beginWithClear(0, 0, 0, 0);
for(int i=0; i<360; i+= 15) {
float radians = CC_DEGREES_TO_RADIANS(i);
label->cocos2d::CCNode::setPosition(center.x + sin(radians)*size, center.y + cos(radians)*size);
label->visit();
}
rt->end();
label->setPosition(originalPos);
label->setColor(originalColor);
label->setBlendFunc(originalBlend);
float rtX = originalSize.width / 2 + size;
float rtY = originalSize.height / 2 - size;
rt->setPosition(rtX, rtY);
if(rt->getParent() == NULL) label->addChild(rt, -100, TAG_STROKE);
//测试
// CCLayerColor* layer = CCLayerColor::create(ccc4(0, 0, 0, 128), wid, hei);
// layer->setPosition(rt->getPosition());
// label->addChild(layer);
}