本文整理汇总了C++中CCMenuItemFont::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemFont::setColor方法的具体用法?C++ CCMenuItemFont::setColor怎么用?C++ CCMenuItemFont::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemFont
的用法示例。
在下文中一共展示了CCMenuItemFont::setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MainMenu::init()
{
if ( !CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
{
return false;
}
CCLabelTTF *title = CCLabelTTF::create("Rabbit Run", FONT_NAME, 70);
title->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 80));
this->addChild(title);
CCMenuItemFont::setFontName(FONT_NAME);
CCMenuItemFont::setFontSize(50);
char* text[] = {"Score", "Power", "Effect",
"+10", "+20%", "--",
"+20", "+40%", "grow up",
"+10", "+0", "lose weight",
"+0", "+0","hiding"};
for(int i = 0; i < 15; i++)
{
CCLabelTTF *label = CCLabelTTF::create(text[i], FONT_NAME, 50);
label->setPosition(ccp(400 + i%3*300, 550 - i/3*85));
this->addChild(label);
}
char* img[] = {"cabbage.png", "carrot.png", "carrot_ice.png", "carrot_sterlth.png"};
for(int i = 0; i < 4; i++)
{
CCSprite *sprite = CCSprite::create(img[i]);
sprite->setScale(0.2f);
sprite->setPosition(ccp(250, 450 - i*80));
this->addChild(sprite);
}
CCMenuItemFont *startGame = CCMenuItemFont::create("Play", this, menu_selector(MainMenu::startGame));
startGame->setColor(ccc3(0, 255,51));
startGame->setPositionX(-90);
CCMenuItemFont *exitGame = CCMenuItemFont::create("Exit", this, menu_selector(MainMenu::exitGame));
exitGame->setColor(ccc3(255, 0, 0));
exitGame->setPositionX(110);
CCMenu *menu = CCMenu::create(startGame, exitGame, NULL);
menu->setPositionY(120);
menu->setTouchPriority(-201);
this->addChild(menu);
CCLabelTTF *powerBy = CCLabelTTF::create("Power by cocos2d-x", FONT_NAME, 50);
powerBy->setAnchorPoint(ccp(1, 0));
powerBy->setPosition(ccp(SCREEN_WIDTH, 0));
this->addChild(powerBy);
this->setTouchPriority(-200);
this->setTouchMode(kCCTouchesOneByOne);
this->setTouchEnabled(true);
return true;
}
示例2: init
KDbool OverScene::init ( KDvoid )
{
if ( !CCLayer::init ( ) )
{
return KD_FALSE;
}
CCMenuItemFont::setFontSize ( 32 );
CCMenuItemFont::setFontName ( "Arial.ttf" );
CCLayerColor* pLayer = CCLayerColor::create ( ccc4 ( 32, 32, 32, 255 ) );
this->addChild ( pLayer, 1 );
m_pTopScore = CCLabelTTF::create ( "0", "Arial.ttf", 32 );
this->addChild ( m_pTopScore, 3 );
m_pTopScore->setColor ( ccc3 ( 255, 0, 0 ) );
m_pTopScore->setPosition ( ccp ( 160, 370 - 50 ) );
m_pScore = CCLabelTTF::create ( "0", "Arial.ttf", 32 );
this->addChild ( m_pScore, 3 );
m_pScore->setColor ( ccc3 ( 0, 0, 255 ) );
m_pScore->setPosition ( ccp ( 160, 320 - 40 ) );
CCMenuItemFont* pReStart = CCMenuItemFont::create ( "RESTART", this, menu_selector ( OverScene::onReStart ) );
pReStart->setColor ( ccc3 ( 0x00, 0xCC, 0x00 ) );
CCMenu* pMenu = CCMenu::create ( pReStart, KD_NULL );
pMenu->setPosition ( ccpMid ( m_tContentSize ) );
pMenu->alignItemsVerticallyWithPadding ( 20.0f );
this->addChild ( pMenu, 2 );
return KD_TRUE;
}
示例3: displayDetail
void MyBuildingCard::displayDetail(cocos2d::CCNode *psender){
MyBuildingCard* card = (MyBuildingCard*)psender->getParent()->getParent();
activeCard = card;
oriPosition = card->getPosition();
card->runAction(CCEaseInOut::create(CCMoveTo::create(0.2, ccp(200-card->getParent()->getPosition().x,320)),2));
card->runAction(CCEaseInOut::create(CCScaleTo::create(0.2, 1.2),2));
card->isEnabled = false;
((GXScrollView*)(card->getParent()))->setEnabled(false);
card->getParent()->reorderChild(card, 100000);
CCMenuItemSprite* gray = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("dialoggray.png"), CCSprite::createWithSpriteFrameName("dialoggray.png"));
MyPriorityMenu* grayMenu = MyPriorityMenu::create(-503,gray,NULL);
grayMenu->setTag(grayTag);
card->getParent()->addChild(grayMenu,99999);
gray->setScaleX(960/gray->getContentSize().width);
gray->setScaleY(540/gray->getContentSize().height);
grayMenu->setPosition(ccp(480-card->getParent()->getPosition().x,320));
// gray->setPosition(ccp(0,0));
CCSprite* detailBack = CCSprite::createWithSpriteFrameName("creatoruidetail.jpg"); detailBack->setPosition(ccp(634-card->getParent()->getPosition().x,-detailBack->getContentSize().height/2-100));
detailBack->setScale(1.2);
detailBack->setTag(detailBackTag);
card->getParent()->addChild(detailBack,100000);
detailBack->runAction(CCSequence::create(CCDelayTime::create(0.2),CCEaseInOut::create(CCMoveTo::create(0.2, ccp(634-card->getParent()->getPosition().x,320)),2), NULL));
CCMenuItemFont::setFontSize(24);
CCMenuItemFont* back = CCMenuItemFont::create("返回",this,menu_selector(MyBuildingCard::cancelDetail));
back->setColor(ccc3(114,66,45));
MyPriorityMenu* backMenu = MyPriorityMenu::create(-503,back,NULL);
backMenu->setPosition(ccp(detailBack->getContentSize().width-44,44));
detailBack->addChild(backMenu,NULL);
}
示例4: alignmentChanged
void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::CCObject *sender)
{
CCMenuItemFont *item = (CCMenuItemFont*)sender;
item->setColor(ccRED);
this->m_pLastAlignmentItem->setColor(ccWHITE);
this->m_pLastAlignmentItem = item;
switch(item->getTag())
{
case LeftAlign:
this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentLeft);
break;
case CenterAlign:
this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentCenter);
break;
case RightAlign:
this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentRight);
break;
default:
break;
}
this->snapArrowsToEdge();
}
示例5: createGameScene
cocos2d::CCNode* SceneEditorTestLayer::createGameScene()
{
CCNode *pNode = CCJsonReader::sharedJsonReader()->createNodeWithJsonFile("FishJoy2.json");
if (pNode == NULL)
{
return NULL;
}
m_pCurNode = pNode;
//play back music
CCComAudio *pAudio = (CCComAudio*)(pNode->getComponent("Audio"));
pAudio->playBackgroundMusic(pAudio->getFile(), pAudio->getIsLoop());
//fishes
CCArmature *pBlowFish = getFish(5, "blowFish");
CCArmature *pButterFlyFish = getFish(6, "butterFlyFish");
pBlowFish->getAnimation()->playByIndex(0);
pButterFlyFish->getAnimation()->playByIndex(0);
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(SceneEditorTestLayer::toExtensionsMainLayer));
itemBack->setColor(ccc3(255, 255, 255));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
menuBack->setZOrder(4);
pNode->addChild(menuBack);
//ui action
cocos2d::extension::UIActionManager::shareManager()->PlayActionByName("startMenu_1.json","Animation1");
return pNode;
}
示例6: createGameScene
cocos2d::CCNode* SceneEditorTestLayer::createGameScene()
{
CCNode *pNode = CCSSceneReader::sharedSceneReader()->createNodeWithSceneFile("scenetest/FishJoy2.json");
if (pNode == NULL)
{
return NULL;
}
m_pCurNode = pNode;
//fishes
CCArmature *pBlowFish = getFish(10008, "blowFish");
CCArmature *pButterFlyFish = getFish(10009, "butterFlyFish");
pBlowFish->getAnimation()->playByIndex(0);
pButterFlyFish->getAnimation()->playByIndex(0);
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(SceneEditorTestLayer::toExtensionsMainLayer));
itemBack->setColor(ccc3(255, 255, 255));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
menuBack->setZOrder(4);
pNode->addChild(menuBack);
//ui action
cocos2d::extension::UIActionManager::shareManager()->PlayActionByName("startMenu_1.json","Animation1");
return pNode;
}
示例7: createGameScene
cocos2d::CCNode* ComponentsTestLayer::createGameScene()
{
CCNode *root = NULL;
do
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite *player = CCSprite::create("components/Player.png", CCRectMake(0, 0, 27, 40) );
player->setPosition( ccp(origin.x + player->getContentSize().width/2,
origin.y + visibleSize.height/2) );
root = cocos2d::CCNode::create();
root->addChild(player, 1, 1);
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(ComponentsTestLayer::toExtensionsMainLayer));
itemBack->setColor(ccc3(0, 0, 0));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
}while (0);
return root;
}
示例8: init
bool BoxMenu::init()
{
if(!CCLayer::init())
{
return false;
}
CCMenu *teamMenu;
CCMenuItemFont::setFontName("΢ÈíÑźÚ");
CCMenuItemFont::setFontSize(20);
teamMenu = getBoxMenu();
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
string gameTitle = GameTitleString;
GBKToUTF8(gameTitle,"gbk","utf-8");
CCMenuItemFont::setFontSize(26);
CCMenuItemFont *titleItem = CCMenuItemFont::create(gameTitle.c_str(), this, menu_selector(BoxMenu::scoreSort));
titleItem->setColor(ccc3(0xc3, 0xa8, 0x91));
titleItem->setPosition(CCPointMake(0, winSize.height/2 - 30));
teamMenu->addChild(titleItem);
CCSprite *backgroudSprite = CCSprite::create(mainBackgroudFile);
backgroudSprite->setPosition(CCPointMake(winSize.width/2, winSize.height/2));
addChild(teamMenu, 0);
addChild(backgroudSprite, -2);
return true;
}
示例9: init
bool ActorBoardLayer::init()
{
bool bRet =false;
do {
CC_BREAK_IF(!CCLayer::init());
setTouchEnabled(true);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* background = CCSprite::createWithSpriteFrameName("bg_over.png");
background->setAnchorPoint(ccp(0, 0));
this->addChild(background);
CCSize size1 = background->getContentSize();
float scale1 = winSize.width/size1.width;
float scale2 = winSize.height/size1.height;
background->setScaleX(scale1);
background->setScaleY(scale2);
CCMenuItemFont *add = CCMenuItemFont::create("关闭", this, menu_selector(ActorBoardLayer::closeMe));
add->setPosition(CCPointZero);
add->setFontSizeObj(35);
add->setColor(ccRED);
CCMenu *menu0 = CCMenu::createWithItem(add);
menu0->setPosition( winSize.width-150, winSize.height-100);
this->addChild(menu0);
m_Htab = HTabGroupLayerBase::create();
m_Htab->creatTabsWithCount(this, 4,AlignLeft,winSize);
m_Htab->setAnchorPoint(CCPointZero);
m_Htab->setPosition(0, 0);
this->addChild(m_Htab);
bRet = true;
} while (0);
return bRet;
}
示例10: init
bool GameOverLayer::init()
{
if ( CCLayerColor::initWithColor( ccc4(255,255,255,255) ) )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
this->_label = CCLabelTTF::create("","Artial", 32);
_label->retain();
_label->setColor( ccc3(0, 0, 0) );
_label->setPosition( ccp(winSize.width/2, winSize.height/2) );
this->addChild(_label);
this->runAction( CCSequence::create(
CCDelayTime::create(3),
CCCallFunc::create(this,
callfunc_selector(GameOverLayer::gameOverDone)),
NULL));
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(ComponentsTestLayer::toExtensionsMainLayer));
itemBack->setColor(ccc3(0, 0, 0));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
return true;
}
else
{
return false;
}
}
示例11: stringChanged
void BitmapFontMultiLineAlignment::stringChanged(cocos2d::CCObject *sender)
{
CCMenuItemFont *item = (CCMenuItemFont*)sender;
item->setColor(ccRED);
this->m_pLastAlignmentItem->setColor(ccWHITE);
this->m_pLastAlignmentItem = item;
switch(item->getTag())
{
case LongSentences:
this->m_pLabelShouldRetain->setString(LongSentencesExample);
break;
case LineBreaks:
this->m_pLabelShouldRetain->setString(LineBreaksExample);
break;
case Mixed:
this->m_pLabelShouldRetain->setString(MixedExample);
break;
default:
break;
}
this->snapArrowsToEdge();
}
示例12: initWithQuantityOfNodes
////////////////////////////////////////////////////////
//
// NodeChildrenMainScene
//
////////////////////////////////////////////////////////
void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
{
//srand(time());
CCSize s = CCDirector::sharedDirector()->getWinSize();
// Title
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(ccp(s.width/2, s.height-32));
label->setColor(ccc3(255,255,40));
// Subtitle
std::string strSubTitle = subtitle();
if(strSubTitle.length())
{
CCLabelTTF *l = CCLabelTTF::create(strSubTitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(s.width/2, s.height-80));
}
lastRenderedCount = 0;
currentQuantityOfNodes = 0;
quantityOfNodes = nNodes;
CCMenuItemFont::setFontSize(65);
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(NodeChildrenMainScene::onDecrease));
decrease->setColor(ccc3(0,200,20));
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(NodeChildrenMainScene::onIncrease));
increase->setColor(ccc3(0,200,20));
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(ccp(s.width/2, s.height/2+15));
addChild(menu, 1);
CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(ccc3(0,200,20));
infoLabel->setPosition(ccp(s.width/2, s.height/2-15));
addChild(infoLabel, 1, kTagInfoLayer);
NodeChildrenMenuLayer* pMenu = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase);
addChild(pMenu);
pMenu->release();
updateQuantityLabel();
updateQuantityOfNodes();
}
示例13: init
bool HelloWorld::init()
{
if ( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) ) {
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite* bg = CCSprite::create("bg.png");
bg->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(bg, 0, 0);
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
CCMenuItemFont* sBtn = CCMenuItemFont::create("", this, menu_selector(HelloWorld::btnCB));
sBtn->setTag(SBTNTAG);
sBtn->setAnchorPoint(CCPointZero);
sBtn->setPosition(50, 200);
sBtn->setColor(ccRED);
CCMenuItemFont* rbtn = CCMenuItemFont::create("", this, menu_selector(HelloWorld::btnCB));
rbtn->setTag(RTBTNTAG);
rbtn->setAnchorPoint(CCPointZero);
rbtn->setPosition(50, 300);
rbtn->setColor(ccGREEN);
// create menu, it's an autorelease object
pMenu = CCMenu::create(pCloseItem, sBtn, rbtn, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
// show filter node
this->setAnchorPoint(CCPointZero);
fnode = GaussianBlur::screenBlurNodeInstance();
fnode->reset(this);
this->addChild(fnode);
updateBtn(SBTNTAG);
updateBtn(RTBTNTAG);
return true;
}
示例14: createPauseLayer
void GameLayer::createPauseLayer() {
Context *context = Context::sharedContext();
CCSize s = CCDirector::sharedDirector()->getWinSize();
/* 半透明层 */
CCLayerColor* pauseLayer = CCLayerColor::create();
pauseLayer->setContentSize(CCSizeMake(s.width, s.height));
pauseLayer->setColor(ccc3(0, 0, 0));
pauseLayer->setOpacity(150);
CCMenu *menu = CCMenu::create();
//回到游戏
CCMenuItemImage *resumebg = CCMenuItemImage::create(("btn_big.png"),
("btn_big.png"));
resumebg->setTarget(this, menu_selector(GameLayer::onResumeItem));
CCMenuItemFont *resumetxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_resume")->getCString());
resumebg->setAnchorPoint(ccp(0.5, 0.5));
resumebg->setPosition(ccpp(0, 0));
resumetxt->setPosition(
ccp(resumebg->getContentSize().width / 2,
resumebg->getContentSize().height / 2));
resumetxt->setAnchorPoint(ccp(0.5, 0.5));
resumetxt->setColor(context->getFontColor());
resumebg->addChild(resumetxt);
menu->addChild(resumebg);
//回到菜单
CCMenuItemImage *backbg = CCMenuItemImage::create(("btn_big.png"),
("btn_big.png"));
backbg->setTarget(this, menu_selector(GameLayer::onBackItem));
CCMenuItemFont *backtxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_back")->getCString());
backbg->setAnchorPoint(ccp(0.5, 0.5));
backbg->setPosition(ccpp(0, -0.12));
backtxt->setPosition(
ccp(backbg->getContentSize().width / 2,
backbg->getContentSize().height / 2));
backtxt->setAnchorPoint(ccp(0.5, 0.5));
backtxt->setColor(context->getFontColor());
backbg->addChild(backtxt);
menu->addChild(backbg);
pauseLayer->addChild(menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(pauseLayer, 0,
TAG_LAYER_PAUSE);
}
示例15: onEnter
void TestPerformance::onEnter()
{
ArmatureTestLayer::onEnter();
CCMenuItemFont::setFontSize(65);
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(TestPerformance::onDecrease));
decrease->setColor(ccc3(0,200,20));
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(TestPerformance::onIncrease));
increase->setColor(ccc3(0,200,20));
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(ccp(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height-100));
addChild(menu, 10000);
armatureCount = frames = times = lastTimes = 0;
generated = false;
scheduleUpdate();
addArmature(100);
}