当前位置: 首页>>代码示例>>C++>>正文


C++ CCLabelTTF::addChild方法代码示例

本文整理汇总了C++中CCLabelTTF::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::addChild方法的具体用法?C++ CCLabelTTF::addChild怎么用?C++ CCLabelTTF::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLabelTTF的用法示例。


在下文中一共展示了CCLabelTTF::addChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initCircleContent

void GameLotteryLayer::initCircleContent()
{
	for(int i = 0; i < CIRCLE_CONTENT_COUNT; i++)
	{
		CCLabelTTF* ptrLbReward = CCLabelTTF::create(Utils::itoa(CircleContent[i]).c_str(), FontConstant::TTF_IMPACT, 18);
		ptrLbReward->setRotation(20 + 45 * i);
		m_ptrCircle->addChild(ptrLbReward, 1);
		ptrLbReward->setPosition(ccp(ChipAmountPositionOffsetX[i], ChipAmountPositionOffsetY[i]));
		m_ptrLbMutilply[i] = CCLabelTTF::create("", FontConstant::TTF_IMPACT, 18);
		//m_ptrLbMutilply[i]->setAnchorPoint(ccp(0, 0.5f));
		m_ptrLbMutilply[i]->setColor(ccc3(0,255,255));
		m_ptrLbMutilply[i]->setRotation(15.0f);
		ptrLbReward->addChild(m_ptrLbMutilply[i]);
		LayoutUtil::layoutParentRight(m_ptrLbMutilply[i], 20, -3);
	}
}
开发者ID:forappengine,项目名称:texasholdem,代码行数:16,代码来源:GameLotteryLayer.cpp

示例2: if

void CSPlayerControlLayer::NextTips1()
{
	m_nSequence++;
	if (m_nSequence == 1)
	{
		m_pRudderMenuItem->setIsEnabled(false);
		m_pImageItemWallet->setIsEnabled(false);
		
		string str = "淘金客时代是最疯狂的时代,听过太多一夜暴富的故事\n我怀揣着仅有的5个金币也开始了伟大的航行!";
		DataManager::GBKToUTF8(str);
		m_pLabel->setString(str.c_str());
		
		CCFiniteTimeAction*  action = CCSequence::actions(
														  CCMoveTo::actionWithDuration(0, CCPointMake(240, 160)),
														  CCFadeIn::actionWithDuration(2),
														  CCDelayTime::actionWithDuration(15),
														  CCMoveBy::actionWithDuration(3, CCPointMake(0, 60)),
														  CCFadeOut::actionWithDuration(3),
														  CCCallFuncN::actionWithTarget(this, callfuncN_selector(CSPlayerControlLayer::NextTips)), 
														  NULL);
		
		m_pLabel->runAction(action);
	}
	else if(m_nSequence == 2)
	{
		char tempInfo[64];
		sprintf(tempInfo, "游戏目标:金币数达到%d", DataManager::sharedDataManager()->xmlWingold());
		//DataManager::GBKToUTF8(str1);
		CCLabelTTF *pLabel = CCLabelTTF::labelWithString(tempInfo, "Arial", 25);
		pLabel->setColor(ccRED);
		addChild(pLabel, ZORDER_HIGHEST);
		pLabel->setPosition(ccp(240, 280));
		
		CCSprite *pSprite = CCSprite::spriteWithSpriteFrameName("goldcoin.png");
		pLabel->addChild(pSprite, ZORDER_HIGHEST);
		pSprite->setPosition(ccp(pLabel->getContentSize().width + pSprite->getContentSize().width, pLabel->getContentSize().height/2));
		
		CCFiniteTimeAction*  action = CCSequence::actions(
														  CCMoveTo::actionWithDuration(0, CCPointMake(240, 160)),
														  CCFadeIn::actionWithDuration(1),
														  CCBlink::actionWithDuration(5, 10),
														  CCMoveBy::actionWithDuration(2, CCPointMake(0, 110)),
														  CCCallFuncN::actionWithTarget(this, callfuncN_selector(CSPlayerControlLayer::NextTips)), 
														  NULL);
		
		pLabel->runAction(action);
	}
	
	else if(m_nSequence == 3)
	{
		m_pImageItemWallet->setIsEnabled(true);
		m_pRudderMenuItem->setIsEnabled(true);

		string str = "请部署船员!(点击钱袋)";
		DataManager::GBKToUTF8(str);
		m_pLabel->setString(str.c_str());	
		
		CCFiniteTimeAction*  action = CCSequence::actions(
														  CCMoveTo::actionWithDuration(0, CCPointMake(240, 160)),
														  CCFadeIn::actionWithDuration(1),
														  CCBlink::actionWithDuration(5, 10),
														  NULL);
		
		m_pLabel->runAction(action);
		m_pImageItemWallet->runAction(m_action);
	}
	else if(m_nSequence == 4)
	{
		m_pImageItemWallet->stopAllActions();
		m_pImageItemWallet->setIsEnabled(false);

		string str = "部署完成,启动船舵起航!";
		DataManager::GBKToUTF8(str);
		m_pLabel->setString(str.c_str());
		
		CCFiniteTimeAction*  action = CCSequence::actions(
														  CCFadeOut::actionWithDuration(0),
														  CCMoveTo::actionWithDuration(0, CCPointMake(240, 160)),
														  CCFadeIn::actionWithDuration(1),
														  CCBlink::actionWithDuration(5, 10),
														  NULL);
		m_pLabel->runAction(action);
		m_pRudderMenuItem->runAction(m_action);
//		CSController::sharedController()->NextRound();
//		m_pRudderMenuItem->selected();	
	}
	else if(m_nSequence == 5)
	{
		m_pRudderMenuItem->setIsEnabled(false);
		m_pRudderMenuItem->stopAllActions();
		
		string str = "等待游戏结束!";
		DataManager::GBKToUTF8(str);
		m_pLabel->setString(str.c_str());
		
		CCFiniteTimeAction*  action = CCSequence::actions(
														  CCFadeOut::actionWithDuration(0),
														  CCMoveTo::actionWithDuration(0, CCPointMake(240, 160)),
														  CCFadeIn::actionWithDuration(1),
														  CCBlink::actionWithDuration(5, 10),
//.........这里部分代码省略.........
开发者ID:calfjohn,项目名称:GoldRush,代码行数:101,代码来源:CSPlayerControlLayer.cpp

示例3: onEnter

void ZhuangbeiXilianUI::onEnter()
{
	BaseLayer::onEnter();

	CCMenu *menu = CCMenu::create();
	menu->setAnchorPoint(CCPointZero);
	menu->setPosition(CCPointZero);
	addChild(menu);
	m_mMenu = menu;
	/*
	CCMenuItemImage *item = CCMenuItemImage::create("CloseNormal.png","CloseSelected.png",this,SEL_MenuHandler(&MainLayerUI::click));
	menu->addChild(item);
	item->setAnchorPoint(CCPointZero);
	item->setPosition(CCPointZero);
	*/
	{
		int max = 0;
		if (mEquipment->getEquipColor() == ZhuangbeiColour_Xiyou)
		{
			max = 23;
		}
		else if (mEquipment->getEquipColor() == ZhuangbeiColour_Chuanqi)
		{
			max = 50;
		}

		CCLabelTTF *titleTTF = CCLabelTTF::create();
		CCLabelTTF *ttf1 = CCLabelTTF::create(LFStrings::getValue("XilianFanwei").c_str(),fontStr_kaiti, 25.0f);
		ttf1->setColor(ccc3(195,145,96));
		ttf1->setPosition(ccp(ttf1->getContentSize().width / 2, ttf1->getContentSize().height / 2));
		//
		titleTTF->addChild(ttf1);

		CCLabelTTF *ttf2 = CCLabelTTF::create(CCString::createWithFormat(" %s1~%d%s%%",LFStrings::getValue("dakuohaoLeft").c_str(),max,LFStrings::getValue("dakuohaoRight").c_str())->getCString(),fontStr_kaiti, 25.0f);
		ttf2->setColor(ccc3(79,110,217));
		ttf2->setPosition(ccp(ttf2->getContentSize().width / 2 + ttf1->getContentSize().width, ttf2->getContentSize().height / 2));
		//ttf1->setPosition(ccp(this->getContentSize().width / 2,645));
		titleTTF->addChild(ttf2);
		titleTTF->setPosition(ccp(this->getContentSize().width / 2 - ( ttf1->getContentSize().width + ttf2->getContentSize().width ) / 2,655));
		addChild(titleTTF);
	}
	

	
	CCLabelTTF *nameTTF = CCLabelTTF::create(mEquipment->getName().c_str(),fontStr_kaiti, 30.0f);
	nameTTF->setPosition(POS_EqName);

	switch (mEquipment->getEquipColor())
	{
	case ZhuangbeiColour_Xiyou:
		{
			nameTTF->setColor(ccc3(253,180,40));
		}
		break;
	case ZhuangbeiColour_Chuanqi:
		{
			nameTTF->setColor(ccc3(181,93,6));
		}
		break;
	default:
		break;
	}
	
	m_sBackSpr->addChild(nameTTF);

	{
		CCMenuItemImage* closeItem = CCMenuItemImage::create(
			"close.png",
			"close_select.png",
			this,menu_selector(ZhuangbeiXilianUI::cilickClose)    
			);
		CCPoint pos = POS_EqName;
		closeItem->setPosition(ccp(m_sBackSpr->getContentSize().width - closeItem->getContentSize().width,pos.y));
		m_mMenu->addChild(closeItem);
	}
	

	CCSprite *shuomingSpr = CCSprite::create("zhuangbei_xiangxi_xilian_shuoming_1.png");

	shuomingSpr->setPosition(POS_ShuoMing);
	m_sBackSpr->addChild(shuomingSpr);

	bool isFirstIn = false;
	if (!History::getHistory()->getBoolFromCurrentHero(Key_First_LookXilianShuoming,isFirstIn))
	{
		History::getHistory()->putInCurrentHero(Key_First_LookXilianShuoming,false);
		CCPoint pos = shuomingSpr->getParent()->convertToWorldSpace(shuomingSpr->getPosition());
		GuideLayerBase *guideLayer = new GuideLayer_SimpleLayer;
		guideLayer->init(shuomingSpr->getContentSize(), pos
			, LFStrings::getValue("first_chuanqi_shuoming"), NULL, false);
		CCDirector::sharedDirector()->getRunningScene()->addChild(guideLayer, 1024);
	}

	CCMenuItemImage *item = CCMenuItemImage::create("zhuangbei_xiangxi_xilian.png","zhuangbei_xiangxi_xilian_select.png",this,SEL_MenuHandler(&ZhuangbeiXilianUI::clickXilian));
	menu->addChild(item);
	item->setPosition(ccp(POS_ShuoMing.x,50));

	CCMenuItemImage *shuomingItem = CCMenuItemImage::create("xuesejiaotang_anniu_shuoming.png","xuesejiaotang_anniu_shuoming_select.png",this,SEL_MenuHandler(&ZhuangbeiXilianUI::clickShuoming));
	menu->addChild(shuomingItem);
	shuomingItem->setPosition(ccp(shuomingItem->getContentSize().width / 2 + 10,POS_ShuoMing.y));
//.........这里部分代码省略.........
开发者ID:longguai,项目名称:game-DarkWar,代码行数:101,代码来源:ZhuangbeiXilianUI.cpp


注:本文中的CCLabelTTF::addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。