本文整理汇总了C++中CCRenderTexture::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ CCRenderTexture::clear方法的具体用法?C++ CCRenderTexture::clear怎么用?C++ CCRenderTexture::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCRenderTexture
的用法示例。
在下文中一共展示了CCRenderTexture::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createStroke
CCRenderTexture* UILabelTTF::createStroke(CCLabelTTF* label, float size ,ccColor3B cor)
{
float RealSize = size;
if(label == NULL || label->getTexture() == NULL)
{
return NULL;
}
label->setAnchorPoint(ccp(0.5, 0.5));
CCRenderTexture* rt = CCRenderTexture::create(label->getContentSize().width + RealSize*2, label->getContentSize().height + RealSize*2);
rt->setAnchorPoint(ccp(0.0,0.0));
rt->setPosition(0,0);
if(rt->getSprite() && rt->getSprite()->getTexture())
{
rt->getSprite()->getTexture()->setAntiAliasTexParameters();
rt->getSprite()->setOpacityModifyRGB(true);
}
else
{
CCLog("UILabelTTF null texture");
}
CCPoint originalPos = label->getPosition();
ccColor3B originalColor = label->getColor();
bool originalVisibility = label->isVisible();
label->setColor(cor);
label->setVisible(true);
ccBlendFunc originalBlend = label->getBlendFunc();
ccBlendFunc tBlendFunc = {GL_SRC_ALPHA, GL_ONE };
label->setBlendFunc(tBlendFunc);
rt->clear(0, 0, 0, 0);
CCPoint center = ccp(label->getContentSize().width/2 ,label->getContentSize().height /2 );
rt->begin();
label->setPosition(ccp(center.x, center.y - RealSize));
label->visit();
label->setPosition(ccp(center.x + 2*RealSize, center.y - 2*RealSize));
label->visit();
label->setPosition(ccp(center.x + RealSize, center.y));
label->visit();
label->setPosition(ccp(center.x + 2*RealSize, center.y - RealSize));
label->visit();
label->setColor(originalColor);
label->setPosition(ccp(center.x,center.y));
label->visit();
rt->end();
label->setBlendFunc(originalBlend);
label->setVisible(originalVisibility);
label->setPosition(originalPos);
// for test
//char file[100];
//sprintf(file,"../../temp/%s_creat.png",label->getString());
//rt->saveToFile(file,kCCImageFormatPNG);
return rt;
}
示例2: onEnter
void CCTransitionRadialCCW::onEnter()
{
CCTransitionScene::onEnter();
// create a transparent color layer
// in which we are going to add our rendertextures
CCSize size = CCDirector::sharedDirector()->getWinSize();
// create the second render texture for outScene
CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
if (NULL == outTexture)
{
return;
}
outTexture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
outTexture->setPosition(ccp(size.width/2, size.height/2));
outTexture->setAnchorPoint(ccp(0.5f,0.5f));
// render outScene to its texturebuffer
outTexture->clear(0,0,0,1);
outTexture->begin();
m_pOutScene->visit();
outTexture->end();
// Since we've passed the outScene to the texture we don't need it.
this->hideOutShowIn();
// We need the texture in RenderTexture.
CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(outTexture->getSprite()->getTexture());
// but it's flipped upside down so we flip the sprite
outNode->getSprite()->setFlipY(true);
// Return the radial type that we want to use
outNode->setType(radialType());
outNode->setPercentage(100.f);
outNode->setPosition(ccp(size.width/2, size.height/2));
outNode->setAnchorPoint(ccp(0.5f,0.5f));
// create the blend action
CCAction * layerAction = CCSequence::actions
(
CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
NULL
);
// run the blend action
outNode->runAction(layerAction);
// add the layer (which contains our two rendertextures) to the scene
this->addChild(outNode, 2, kSceneRadial);
}
示例3: onEnter
// CCTransitionProgress
void CCTransitionProgress::onEnter()
{
CCTransitionScene::onEnter();
setupTransition();
// create a transparent color layer
// in which we are going to add our rendertextures
CCSize size = CCDirector::sharedDirector()->getWinSize();
// create the second render texture for outScene
CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
texture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
texture->setPosition(ccp(size.width/2, size.height/2));
texture->setAnchorPoint(ccp(0.5f,0.5f));
// render outScene to its texturebuffer
texture->clear(0, 0, 0, 1);
texture->begin();
m_pSceneToBeModified->visit();
texture->end();
// Since we've passed the outScene to the texture we don't need it.
if (m_pSceneToBeModified == m_pOutScene)
{
hideOutShowIn();
}
// We need the texture in RenderTexture.
CCProgressTimer *pNode = progressTimerNodeWithRenderTexture(texture);
// create the blend action
CCActionInterval* layerAction = (CCActionInterval*)CCSequence::create(
CCProgressFromTo::create(m_fDuration, m_fFrom, m_fTo),
CCCallFunc::create(this, callfunc_selector(CCTransitionProgress::finish)),
NULL);
// run the blend action
pNode->runAction(layerAction);
// add the layer (which contains our two rendertextures) to the scene
addChild(pNode, 2, kCCSceneRadial);
}