const ccColor3B& UIWidget::getColor() { CCRGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL; if (rgbap) { return rgbap->getColor(); } return ccWHITE; }
void CCTintTo::startWithTarget(CCNode *pTarget) { CCActionInterval::startWithTarget(pTarget); CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget); if (pRGBAProtocol) { m_from = pRGBAProtocol->getColor(); } /*m_from = pTarget->getColor();*/ }
void CCTintTo::startWithTarget(CCNode *pTarget) { CCActionInterval::startWithTarget(pTarget); CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol(); if (pRGBAProtocol) { m_from = pRGBAProtocol->getColor(); } /*m_from = pTarget->getColor();*/ }
void CCTintBy::startWithTarget(CCNode *pTarget) { CCActionInterval::startWithTarget(pTarget); CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(pTarget); if (pRGBAProtocol) { ccColor3B color = pRGBAProtocol->getColor(); m_fromR = color.r; m_fromG = color.g; m_fromB = color.b; } }
void CCTintBy::startWithTarget(CCNode *pTarget) { CCActionInterval::startWithTarget(pTarget); CCRGBAProtocol *pRGBAProtocol = pTarget->convertToRGBAProtocol(); if (pRGBAProtocol) { ccColor3B color = pRGBAProtocol->getColor(); m_fromR = color.r; m_fromG = color.g; m_fromB = color.b; } }
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(); } }
bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Sprite* backgroundSprite) { if (CCControl::init()) { CCAssert(node != NULL, "Label must not be nil."); CCLabelProtocol* label = dynamic_cast<CCLabelProtocol*>(node); CCRGBAProtocol* rgbaLabel = dynamic_cast<CCRGBAProtocol*>(node); CCAssert(backgroundSprite != NULL, "Background sprite must not be nil."); CCAssert(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL, ""); m_bParentInited = true; // Initialize the button state tables this->setTitleDispatchTable(CCDictionary::create()); this->setTitleColorDispatchTable(CCDictionary::create()); this->setTitleLabelDispatchTable(CCDictionary::create()); this->setBackgroundSpriteDispatchTable(CCDictionary::create()); setTouchEnabled(true); m_isPushed = false; m_zoomOnTouchDown = true; m_currentTitle=NULL; // Adjust the background image by default setAdjustBackgroundImage(true); setPreferredSize(CCSizeZero); // Zooming button by default m_zoomOnTouchDown = true; // Set the default anchor point ignoreAnchorPointForPosition(false); setAnchorPoint(ccp(0.5f, 0.5f)); // Set the nodes setTitleLabel(node); setBackgroundSprite(backgroundSprite); // Set the default color and opacity setColor(ccc3(255.0f, 255.0f, 255.0f)); setOpacity(255.0f); setOpacityModifyRGB(true); // Initialize the dispatch table CCString* tempString = CCString::create(label->getString()); //tempString->autorelease(); setTitleForState(tempString, CCControlStateNormal); setTitleColorForState(rgbaLabel->getColor(), CCControlStateNormal); setTitleLabelForState(node, CCControlStateNormal); setBackgroundSpriteForState(backgroundSprite, CCControlStateNormal); setLabelAnchorPoint(ccp(0.5f, 0.5f)); // Layout update needsLayout(); return true; } //couldn't init the CCControl else { return false; } }