本文整理汇总了C++中CCLabelTTF::setFontFillColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setFontFillColor方法的具体用法?C++ CCLabelTTF::setFontFillColor怎么用?C++ CCLabelTTF::setFontFillColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::setFontFillColor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: show
void ShowTip::show(const char *str, cocos2d::CCPoint& point, float fontSize, float delayTime, bool displayBg)
{
CCLabelTTF* ttfTip = CCLabelTTF::create(str, "宋体", fontSize);
ttfTip->cocos2d::CCNode::setAnchorPoint(CCPoint(0, 0));
CCSize size = ttfTip->getContentSize();
CCLayerColor* bgColor = NULL;
if (displayBg)
{
bgColor = CCLayerColor::create();
bgColor->setColor(ccColor3B(ccc3(0, 0, 0)));
bgColor->setAnchorPoint(CCPoint(0.5,0.5));
bgColor->setPosition(CCPoint(point.x - size.width * 0.5, point.y - 40));
bgColor->setContentSize(size);
bgColor->addChild(ttfTip);
this->addChild(bgColor);
ttfTip->setFontFillColor(ccColor3B(ccc3(255, 255, 255)));
}
else
{
size = CCSize(0,0);
ttfTip->setFontFillColor(ccColor3B(ccc3(0, 0, 0)));
ttfTip->setPosition(CCPoint(point.x, point.y - 60));
this->addChild(ttfTip);
}
CCAction* moveTo = CCMoveTo::create(delayTime, CCPoint(point.x - size.width * 0.5, point.y + 40));
if ( displayBg && bgColor )
{
CCFadeIn* fadeIn = CCFadeIn::create(delayTime * 0.25);
CCScaleTo* scaleTo = CCScaleTo::create(delayTime * 0.5, 1);
CCFadeOut* fadeOut = CCFadeOut::create(delayTime * 0.25);
bgColor->runAction(CCSequence::create(fadeIn,scaleTo, fadeOut, NULL));
bgColor->runAction(moveTo);
}
else
{
CCFadeIn* fadeIn = CCFadeIn::create(delayTime * 0.5);
CCFadeOut* fadeOut = CCFadeOut::create(delayTime * 0.5);
ttfTip->runAction(CCSequence::create(fadeIn, fadeOut, NULL));
ttfTip->runAction(moveTo);
}
scheduleOnce(schedule_selector(ShowTip::removeFromParent), delayTime);
}
示例2: showBuySuccessTips
void gameShopClass::showBuySuccessTips(char *showText)
{
CCSprite* showTips = CCSprite::createWithSpriteFrameName("buycheck_bg.png");
showTips->setPosition(ccp(gameShopBgSprite->getContentSize().width/2.0, gameShopBgSprite->getContentSize().height/2.0));
showTips->setScale(0.1);
CCLabelTTF* text = NULL;
if (showText == NULL) {
text = CCLabelTTF::create("兑换物品成功", "Arial", 24);
}
else
{
text = CCLabelTTF::create(showText, "Arial", 24);
}
text->setPosition(ccp(showTips->getContentSize().width * 60 /100.0, showTips->getContentSize().height /2.0));
text->setHorizontalAlignment(kCCTextAlignmentCenter);
ccColor3B color;
color.r = 255;
color.g = 0;
color.b = 0;
text->setFontFillColor(color);
showTips->addChild(text,1);
CCMoveBy* wait = CCMoveBy::create(1, ccp(0, 0));
showTips->runAction(CCSequence::create(CCScaleTo::create(0.2, 1),wait,CCCallFuncN::create(this, callfuncN_selector(gameShopClass::showBuySuccessCallBack)),NULL));
gameShopBgSprite->addChild(showTips,1000);
}
示例3: initWithParentNode
bool RPGBattleMenu::initWithParentNode(CCDictionary* stringList, CppSQLite3DB* db, CCNode* parentNode, RPGPlayer* playerData)
{
if(CCMenu::init())
{
this->m_stringList = stringList;
this->m_stringList->retain();
this->m_db = db;
this->m_parentNode = parentNode;
this->m_parentNode->retain();
this->m_playerData = playerData;
this->m_playerData->retain();
this->m_tableItems = new CCArray();
this->m_tableItems->init();
this->setPosition(CCPointZero);
CCTMXTiledMap *bgLayer = (CCTMXTiledMap*)this->m_parentNode->getChildByTag(kRPGBattleMenuTagBg);
if(!bgLayer)
{
bgLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_battlemenu_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
bgLayer->setPosition(ccp(718, 0));
bgLayer->setTag(kRPGBattleMenuTagBg);
parentNode->addChild(bgLayer);
}
//角色名字
addLab(this->m_parentNode, kRPGBattleMenuTagNameLab, CCString::create(playerData->m_name), 20, kCCTextAlignmentCenter, ccp(798, 228));
CCLabelTTF *nameLab = (CCLabelTTF*)this->m_parentNode->getChildByTag(kRPGBattleMenuTagNameLab);
nameLab->setFontFillColor(ccc3(144, 144, 144));
//分割线
CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
separate->setTag(kRPGBattleMenuTagSeparate);
separate->setPosition(ccp(798, 211));
separate->setScaleX(0.34);
this->m_parentNode->addChild(separate);
CCString *menuAttackStr = (CCString*)this->m_stringList->objectForKey("battle_playermenu_attack");
this->createMenuItem(798, 186, menuAttackStr, kRPGBattleMenuTagAttack);
CCString *menuSkillStr = (CCString*)this->m_stringList->objectForKey("battle_playermenu_skill");
this->createMenuItem(798, 136, menuSkillStr, kRPGBattleMenuTagSkill);
CCString *menuItemsStr = (CCString*)this->m_stringList->objectForKey("battle_playermenu_items");
this->createMenuItem(798, 86, menuItemsStr, kRPGBattleMenuTagItems);
CCString *menuEscapeStr = (CCString*)this->m_stringList->objectForKey("battle_playermenu_escape");
this->createMenuItem(798, 36, menuEscapeStr, kRPGBattleMenuTagEscape);
SimpleAudioEngine::sharedEngine()->playEffect("audio_battle_menu.wav");
return true;
}
return false;
}
示例4: onFinishAnimationRightChoose
void SoloGameScene::onFinishAnimationRightChoose()
{
m_itBack->setEnabled(true);
m_sprGameResult->setVisible(true);
CCLabelTTF* changeScore = dynamic_cast<CCLabelTTF*>(m_sprGameResult->getChildByTag(1));
CCLabelTTF* rightWrong = dynamic_cast<CCLabelTTF*>(m_sprGameResult->getChildByTag(2));
if (NULL != changeScore)
{
if (m_isRight)
{
int solo_add_score = DataManager::sharedDataManager()->GetSoloAddScore();
CCLOG("Add score: %d", solo_add_score);
changeScore->setString(CCString::createWithFormat("+%d", solo_add_score)->getCString());
rightWrong->setString("Đúng !!!");
rightWrong->setFontFillColor(ccc3(0, 162, 255));
rightWrong->setColor(ccc3(0, 162, 255));
}
else
{
int solo_sub_score = DataManager::sharedDataManager()->GetSoloSubScore();
CCLOG("Sub score: %d", solo_sub_score);
changeScore->setString(CCString::createWithFormat("%d", solo_sub_score)->getCString());
rightWrong->setString("Sai !!!");
rightWrong->setFontFillColor(ccc3(193, 0, 0));
rightWrong->setColor(ccc3(193, 0, 0));
}
}
//animation
CCPoint oldPoint = m_sprGameResult->getPosition();
CCPoint newPoint = ccp(400, - m_sprGameResult->getContentSize().height / 2);
m_sprGameResult->setPosition(newPoint);
m_sprGameResult->runAction(CCEaseBackOut::create(CCMoveTo::create(0.5f, oldPoint)));
}
示例5: tableCellTouched
void DebugTestScene::tableCellTouched( CCTableView* in_pTable, CCTableViewCell* in_pCell )
{
// タッチしたシーンに遷移する。
unsigned int idx = in_pCell->getIdx();
CCTableViewCell* pCell = in_pTable->dequeueCell();
if( pCell )
{
CCLabelTTF* pLabel = (CCLabelTTF*)pCell->getChildByTag(100);
pLabel->setFontFillColor(ccc3(255, 0, 0));
}
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->replaceScene((*s_aSelectSceneList[idx].pScene)());
}
示例6: showSettingsMenu
void RPGStartSceneLayer::showSettingsMenu()
{
RPGSaveData *saveDataObj = loadSaveData(&this->m_db);
CCMenu *settingsMenu = CCMenu::create();
settingsMenu->setAnchorPoint(CCPointZero);
settingsMenu->setPosition(CCPointZero);
settingsMenu->setTag(kRPGStartSceneLayerTagSettingsMenu);
this->addChild(settingsMenu);
//设置样式的标题
CCString *labStyleStr = (CCString*)this->m_stringList->objectForKey("settingslab_style");
CCLabelTTF *labStyleLabel = CCLabelTTF::create(OzgCCUtility::generalString(labStyleStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
labStyleLabel->setFontFillColor(ccc3(188, 188, 188));
labStyleLabel->setTag(kRPGStartSceneLayerTagLabStyle);
labStyleLabel->setPosition(ccp(300, 550));
this->addChild(labStyleLabel);
//设置样式的按钮
CCLabelTTF *menuStyleLeftLabel = CCLabelTTF::create("<<", "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStyleLeft = CCMenuItemLabel::create(menuStyleLeftLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStyleLeft->setPosition(ccp(450, 550));
menuStyleLeft->setTag(kRPGStartSceneLayerTagSettingsStyleLeft);
settingsMenu->addChild(menuStyleLeft);
CCLabelTTF *menuStyleRightLabel = CCLabelTTF::create(">>", "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStyleRight = CCMenuItemLabel::create(menuStyleRightLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStyleRight->setPosition(ccp(650, 550));
menuStyleRight->setTag(kRPGStartSceneLayerTagSettingsStyleRight);
settingsMenu->addChild(menuStyleRight);
//设置样式的当前使用样式
CCString *labCurrStyleStr = NULL;
for (int i = 0; i < this->m_styleData.size(); i++)
{
pair<string, string> item = this->m_styleData[i];
if(strcmp(item.first.c_str(), saveDataObj->m_windowStyle.c_str()) == 0)
{
this->m_selectedStyleIndex = i;
labCurrStyleStr = CCString::create(item.second);
break;
}
}
if(labCurrStyleStr)
{
CCLabelTTF *labCurrStyleLabel = CCLabelTTF::create(OzgCCUtility::generalString(labCurrStyleStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
labCurrStyleLabel->setFontFillColor(ccc3(188, 188, 188));
labCurrStyleLabel->setTag(kRPGStartSceneLayerTagLabCurrStyle);
labCurrStyleLabel->setPosition(ccp(550, 550));
this->addChild(labCurrStyleLabel);
}
//恢复默认
CCString *menuRestoreStr = (CCString*)this->m_stringList->objectForKey("settingsmenu_restore");
CCLabelTTF *menuRestoreLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuRestoreStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuRestore = CCMenuItemLabel::create(menuRestoreLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuRestore->setPosition(ccp(300, 170));
menuRestore->setTag(kRPGStartSceneLayerTagSettingsRestore);
settingsMenu->addChild(menuRestore);
//返回
CCString *menuBackStr = (CCString*)this->m_stringList->objectForKey("settingsmenu_back");
CCLabelTTF *menuBackLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuBackStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuBack = CCMenuItemLabel::create(menuBackLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuBack->setPosition(ccp(300, 100));
menuBack->setTag(kRPGStartSceneLayerTagSettingsBack);
settingsMenu->addChild(menuBack);
}
示例7: init
bool SoloGameScene::init()
{
if ( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) )
{
return false;
}
SoloGameScene::QUEST_RESULTS_NUMBER = CONF_INT(QUEST_RESULTS_NUMBER);
m_curScore = DataManager::sharedDataManager()->GetSoloScore();
m_curQuestionNumber = DataManager::sharedDataManager()->GetSoloQuestionNumber();
m_curRightAnswer = -1;
m_clockCounter = CONF_INT(SOLO_TIME_FOR_QUESTION);
m_isRight = false;
m_curDisableChoose = 4;
m_isUsedInfiniteTime = false;
MY_ADD_SPRITE(bg, "game_background.png", ccp(400, 640));
MY_CREATE_SPRITE(defaultAvatar, "avatar.png", ccp(86, 1280-86));
m_defaultAvatar = defaultAvatar;
this->addChild(m_defaultAvatar);
string photoPath = DataManager::sharedDataManager()->GetFbPhotoPath();
if (photoPath.length() > 0)
{
MY_CREATE_SPRITE(fbAvatar, photoPath.c_str(), ccp(86, 1280-86));
m_fbAvatar = fbAvatar;
this->addChild(m_fbAvatar);
m_fbAvatar->setScale((m_defaultAvatar->getContentSize().width - 7) / CONF_INT(AVATAR_SIZE));
}
string name = DataManager::sharedDataManager()->GetName();
name = MY_LIMIT_STR(name, 22, "");
MY_ADD_LABELTTF(lbName, name.c_str(), CONF_STR(FONT_NORMAL), 36, ccBLACK, ccp(12, 1280-195));
m_lbName = lbName;
m_lbName->setAnchorPoint(ANCHOR_LEFT);
MY_ADD_SPRITE(score, "score.png", ccp(203, 1280-41));
MY_ADD_LABELTTF(_lbScore, CCString::createWithFormat("%d", m_curScore)->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, ccp(240, 1280-46));
_lbScore->setAnchorPoint(ANCHOR_LEFT);
m_lbScore = _lbScore;
MY_ADD_SPRITE(sprDiamond, "diamond.png", ccp(203, 1280-100));
int diamond = DataManager::sharedDataManager()->GetDiamond();
MY_ADD_LABELTTF(_lbDiamond, CCString::createWithFormat("%d", diamond)->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, ccp(240, 1280-100));
_lbDiamond->setAnchorPoint(ANCHOR_LEFT);
m_lbDiamond = _lbDiamond;
MY_ADD_SPRITE(sprClock, "clock.png", ccp(400, 1280-200));
MY_ADD_LABELTTF( _lbClock, CCString::createWithFormat("%d", (int)m_clockCounter)->getCString(),
CONF_STR(FONT_NORMAL), 64, ccBLACK, sprClock->getPosition());
_lbClock->setAnchorPoint(ANCHOR_CENTER);
m_lbClock = _lbClock;
m_menu = CCMenu::create();
m_menu->setPosition(CCPointZero);
this->addChild(m_menu);
MY_ADD_MENU_ITEM(itBack, "back.png", "backDown.png", "back.png", SoloGameScene::menuCallback, ccp(60, 60));
m_itBack = itBack;
//HELP
MY_CREATE_MENU_ITEM(itHelp1, "help1.png", "help1Down.png", "help1Down.png", SoloGameScene::itHelp1Callback, ccp(740, 1280-60));
m_menu->addChild(itHelp1);
MY_CREATE_MENU_ITEM(itHelp2, "help2.png", "help2Down.png", "help2Down.png", SoloGameScene::itHelp2Callback, ccp(640, 1280-60));
m_menu->addChild(itHelp2);
MY_CREATE_MENU_ITEM(itHelp3, "help3.png", "help3Down.png", "help3Down.png", SoloGameScene::itHelp3Callback, ccp(540, 1280-60));
m_menu->addChild(itHelp3);
initQuestionItems();
//RESULT //////////////////////////////////////////////////////////////////////////
MY_ADD_SPRITE(_sprGameResult, "game_result.png", ccp(400, 640));
m_sprGameResult = _sprGameResult;
m_sprGameResult->setVisible(false);
//+10 (-5)
CCLabelTTF* changeScore = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 120);
changeScore->setFontFillColor(ccBLACK);
changeScore->setColor(ccBLACK);
changeScore->setAnchorPoint(ANCHOR_RIGHT);
changeScore->setPosition(ccp(380, 1280-880));
changeScore->setTag(1);
m_sprGameResult->addChild(changeScore);
//Right, wrong
CCLabelTTF* rightWrong = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 72);
rightWrong->setFontFillColor(ccBLACK);
rightWrong->setColor(ccBLACK);
rightWrong->setAnchorPoint(ANCHOR_RIGHT);
rightWrong->setPosition(ccp(380, 1280-722));
rightWrong->setTag(2);
m_sprGameResult->addChild(rightWrong);
MY_CREATE_MENU_ITEM(itNext, "next.png", "nextDown.png", "nextDown.png", SoloGameScene::checkBeforeNextQuestion, ccp(400, 1280-879));
itNext->setAnchorPoint(ANCHOR_LEFT);
//.........这里部分代码省略.........
示例8: onMenu
void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject)
{
CCMenuItem *menuItem = (CCMenuItem*)pObject;
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
switch (menuItem->getTag())
{
case kRPGBattleMenuTagSkill:
{
CCLog("技能");
this->hideMenu();
this->m_selectedMenuTag = kRPGBattleMenuTagSkill;
CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
menuCancel->setPosition(ccp(43, 596));
menuCancel->setTag(kRPGBattleMenuTagCancel);
menuCancel->setScale(0.75);
this->addChild(menuCancel);
CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog);
((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);
((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
//显示title和分隔线
addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285));
CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
titleLab->setFontFillColor(ccc3(144, 144, 144));
CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
separate->setScaleX(0.65);
separate->setTag(198);
selectLayer->addChild(separate);
//加载技能数据
CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
if(!tableView)
{
tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(CCSizeZero);
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(197);
selectLayer->addChild(tableView);
}
this->m_tableItems->removeAllObjects();
string wq = "";
JsonBox::Value json;
json.loadFromString(this->m_playerData->m_skill.c_str());
JsonBox::Array jsonArr = json.getArray();
for (int i = 0; i < jsonArr.size(); i++)
{
char* str = (char*)malloc(10 * sizeof(char));
OzgCCUtility::itoa(jsonArr[i].getInt(), str);
wq.append(str);
if(i + 1 < jsonArr.size())
wq.append(", ");
free(str);
}
if((int)wq.length() > 0)
{
CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString());
while(!query.eof())
{
RPGSkillBtnData *skill = RPGSkillBtnData::create();
skill->m_dataId = query.getIntField("id");
skill->m_name = query.getStringField("name_cns");
skill->m_MP = query.getIntField("mp");
skill->m_skillAttack = query.getIntField("skill_attack");
skill->m_type = query.getIntField("type");
skill->m_attr = query.getIntField("attr");
skill->m_enabled = true;
//不能使用技能的情况
if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0)
skill->m_enabled = false;
else if(this->m_playerData->m_MP < skill->m_MP)
skill->m_enabled = false;
this->m_tableItems->addObject(skill);
query.nextRow();
}
query.finalize();
}
tableView->reloadData();
//加载技能数据 end
//.........这里部分代码省略.........