本文整理汇总了C++中CCRGBAProtocol::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CCRGBAProtocol::setColor方法的具体用法?C++ CCRGBAProtocol::setColor怎么用?C++ CCRGBAProtocol::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCRGBAProtocol
的用法示例。
在下文中一共展示了CCRGBAProtocol::setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setColor
void UIWidget::setColor(const ccColor3B &color)
{
CCRGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
if (rgbap)
{
rgbap->setColor(color);
}
}
示例2: updateBackGroundImageColor
void Layout::updateBackGroundImageColor()
{
CCRGBAProtocol* rgba = dynamic_cast<CCRGBAProtocol*>(_backGroundImage);
if (rgba)
{
rgba->setColor(_backGroundImageColor);
}
}
示例3: update
void CCTintBy::update(cocos2d::ccTime time)
{
CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setColor(ccc3((GLubyte)(m_fromR + m_deltaR * time),
(GLubyte)(m_fromG + m_deltaG * time),
(GLubyte)(m_fromB + m_deltaB * time)));
}
}
示例4: update
void CCTintTo::update(ccTime time)
{
CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget);
if (pRGBAProtocol)
{
pRGBAProtocol->setColor(ccc3(CCubyte(m_from.r + (m_to.r - m_from.r) * time),
(CCbyte)(m_from.g + (m_to.g - m_from.g) * time),
(CCbyte)(m_from.b + (m_to.b - m_from.b) * time)));
}
}
示例5: addChild
void GUINodeRGBA::addChild(cocos2d::CCNode *child)
{
CCNode::addChild(child);
CCRGBAProtocol *item = dynamic_cast<CCRGBAProtocol*>(child);
if (item)
{
item->setColor(this->getColor());
item->setOpacity(this->getOpacity());
}
}
示例6: setColor
void UILayout::setColor(const ccColor3B &color)
{
UIWidget::setColor(color);
if (m_pBackGroundImage)
{
CCRGBAProtocol* rgbap = dynamic_cast<CCRGBAProtocol*>(m_pBackGroundImage);
if (rgbap)
{
rgbap->setColor(color);
}
}
}
示例7: setColor
void GUINodeRGBA::setColor(const cocos2d::ccColor3B &color3)
{
CCNodeRGBA::setColor(color3);
CCObject* pObj;
CCARRAY_FOREACH(m_pChildren, pObj)
{
CCRGBAProtocol *item = dynamic_cast<CCRGBAProtocol*>(pObj);
if (item)
{
item->setColor(color3);
}
}
示例8: setColor
//CRGBA protocol
void CCControl::setColor(const ccColor3B& color)
{
m_tColor=color;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setColor(m_tColor);
}
}
示例9: setColor
void CCSpecialSprite::setColor(const ccColor3B & color3)
{
CCSprite::setColor(color3);
Vector<CCNode *>::const_iterator beg = _children.begin();
Vector<CCNode *>::const_iterator end = _children.end();
for (; beg != end; ++beg)
{
CCRGBAProtocol * rgba = dynamic_cast<CCRGBAProtocol *>(*beg);
if (rgba != NULL)
rgba->setColor(color3);
}
}
示例10: addChild
void CCSpecialSprite::addChild(CCNode *pChild, int zOrder, int tag)
{
CCSprite::addChild(pChild, zOrder, tag);
setTexture(((CCSprite*)pChild)->getTexture());
CCRGBAProtocol * rgba = dynamic_cast<CCRGBAProtocol *>(pChild);
if (rgba != NULL)
{
rgba->setColor(this->getColor());
rgba->setOpacity(this->getOpacity());
}
}
示例11: underAttack
void CArmySprite::underAttack(int nHurt)
{
if (m_eCurState >= AS_EXPLODE)
{
return ;
}
m_sCurData.mHealthPoint -= nHurt;
if (m_bIsNormal)
{
m_bIsNormal = false;
CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTurretSprite);
color = pRGBAProtocol->getColor();
pRGBAProtocol->setColor(ccc3(255,0,0));
}
if (m_sCurData.mHealthPoint < 0)
{
m_sCurData.mHealthPoint = 0;
m_eCurState = AS_EXPLODE;
m_pTurretSprite->setVisible(false);
m_pBaseSprite->setVisible(false);
if (m_pCapSprite)
{
m_pCapSprite->setVisible(false);
}
m_pWreckSprite->setVisible(true);
CGlobalData::getSingleton()->addScore(m_sCurData.mScoreValue);
Music::playExplode2Effect();
CGlobalData::getSingleton()->addDesArmyScore(m_sCurLandData.mKind);
ASSESS_DATA mData;
if (CCRANDOM_0_1() > 0.5f)
{
mData.mKind = ASK_PERFECT;
}
else
{
mData.mKind = ASK_DEFAULT;
}
mData.mPos = getPosition();
CAssess *pAssess = CAssess::createAssess(mData);
getParent()->addChild(pAssess, ASSESS_ZORDER);
mData.mKind = ASK_ADD100;
mData.mPos = ccpAdd(mData.mPos, ccp(0, getContentSize().height * 0.5f));
pAssess = CAssess::createAssess(mData);
getParent()->addChild(pAssess, ASSESS_ZORDER);
runEffect();
}
}
示例12:
void CCScale9Sprite::setColor(const ccColor3B& color)
{
_color = color;
CCObject* child;
CCArray* children = this->getSubviews();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setColor(color);
}
}
示例13: setColor
void CCMenu::setColor(cocos2d::ccColor3B var)
{
m_tColor = var;
if (m_pChildren && m_pChildren->count() > 0)
{
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
{
if (! *it)
{
break;
}
CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setColor(m_tColor);
}
}
}
}
示例14: needsLayout
void CCControlButton::needsLayout()
{
if (!m_bParentInited) {
return;
}
// Hide the background and the label
if (m_titleLabel != NULL) {
m_titleLabel->setIsVisible(false);
}
if (m_backgroundSprite) {
m_backgroundSprite->setIsVisible(false);
}
// Update anchor of all labels
this->setLabelAnchorPoint(this->m_labelAnchorPoint);
// Update the label to match with the current state
CC_SAFE_RELEASE(m_currentTitle);
m_currentTitle = getTitleForState(m_eState);
CC_SAFE_RETAIN(m_currentTitle);
m_currentTitleColor=getTitleColorForState(m_eState);
this->setTitleLabel(getTitleLabelForState(m_eState));
CCLabelProtocol* label = dynamic_cast<CCLabelProtocol*>(m_titleLabel);
if (label && m_currentTitle)
{
label->setString(m_currentTitle->toStdString().c_str());
}
CCRGBAProtocol* rgbaLabel = dynamic_cast<CCRGBAProtocol*>(m_titleLabel);
if (rgbaLabel)
{
rgbaLabel->setColor(m_currentTitleColor);
}
if (m_titleLabel != NULL)
{
m_titleLabel->setPosition(ccp (getContentSize().width / 2, getContentSize().height / 2));
}
// Update the background sprite
this->setBackgroundSprite(this->getBackgroundSpriteForState(m_eState));
if (m_backgroundSprite != NULL)
{
m_backgroundSprite->setPosition(ccp (getContentSize().width / 2, getContentSize().height / 2));
}
// Get the title label size
CCSize titleLabelSize;
if (m_titleLabel != NULL)
{
titleLabelSize = m_titleLabel->boundingBox().size;
}
// Adjust the background image if necessary
if (m_doesAdjustBackgroundImage)
{
// Add the margins
if (m_backgroundSprite != NULL)
{
m_backgroundSprite->setContentSize(CCSizeMake(titleLabelSize.width + m_marginH * 2, titleLabelSize.height + m_marginV * 2));
}
}
else
{
//TODO: should this also have margins if one of the preferred sizes is relaxed?
if (m_backgroundSprite != NULL)
{
CCSize preferredSize = m_backgroundSprite->getPreferredSize();
if (preferredSize.width <= 0)
{
preferredSize.width = titleLabelSize.width;
}
if (preferredSize.height <= 0)
{
preferredSize.height = titleLabelSize.height;
}
m_backgroundSprite->setContentSize(preferredSize);
}
}
// Set the content size
CCRect rectTitle;
if (m_titleLabel != NULL)
{
rectTitle = m_titleLabel->boundingBox();
}
CCRect rectBackground;
if (m_backgroundSprite != NULL)
{
rectBackground = m_backgroundSprite->boundingBox();
}
CCRect maxRect = CCControlUtils::CCRectUnion(rectTitle, rectBackground);
setContentSize(CCSizeMake(maxRect.size.width, maxRect.size.height));
if (m_titleLabel != NULL)
{
m_titleLabel->setPosition(ccp(getContentSize().width/2, getContentSize().height/2));
//.........这里部分代码省略.........
示例15: formatText
void RichText::formatText()
{
if (_formatTextDirty)
{
_elementRenderersContainer->removeAllChildren();
_elementRenders.clear();
if (_ignoreSize)
{
addNewLine();
for (unsigned int i=0; i<_richElements->count(); i++)
{
RichElement* element = static_cast<RichElement*>(_richElements->objectAtIndex(i));
CCNode* elementRenderer = NULL;
switch (element->_type)
{
case RICH_TEXT:
{
RichElementText* elmtText = static_cast<RichElementText*>(element);
elementRenderer = CCLabelTTF::create(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize);
break;
}
case RICH_IMAGE:
{
RichElementImage* elmtImage = static_cast<RichElementImage*>(element);
elementRenderer = CCSprite::create(elmtImage->_filePath.c_str());
break;
}
case RICH_CUSTOM:
{
RichElementCustomNode* elmtCustom = static_cast<RichElementCustomNode*>(element);
elementRenderer = elmtCustom->_customNode;
break;
}
default:
break;
}
CCRGBAProtocol* colorRenderer = dynamic_cast<CCRGBAProtocol*>(elementRenderer);
colorRenderer->setColor(element->_color);
colorRenderer->setOpacity(element->_opacity);
pushToContainer(elementRenderer);
}
}
else
{
addNewLine();
for (unsigned int i=0; i<_richElements->count(); i++)
{
RichElement* element = static_cast<RichElement*>(_richElements->objectAtIndex(i));
switch (element->_type)
{
case RICH_TEXT:
{
RichElementText* elmtText = static_cast<RichElementText*>(element);
handleTextRenderer(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize, elmtText->_color, elmtText->_opacity);
break;
}
case RICH_IMAGE:
{
RichElementImage* elmtImage = static_cast<RichElementImage*>(element);
handleImageRenderer(elmtImage->_filePath.c_str(), elmtImage->_color, elmtImage->_opacity);
break;
}
case RICH_CUSTOM:
{
RichElementCustomNode* elmtCustom = static_cast<RichElementCustomNode*>(element);
handleCustomRenderer(elmtCustom->_customNode);
break;
}
default:
break;
}
}
}
formarRenderers();
_formatTextDirty = false;
}
}