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


C++ CCMenuItemSprite::getPositionX方法代码示例

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


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

示例1: InitLayer


//.........这里部分代码省略.........
			CC_BREAK_IF(pBtnCommon==NULL);
			pBtnCommon->setPosition(ccp(SCREEN_WIDTH - 60,58));
			pMenu->addChild(pBtnCommon,enZOrderFront,enTagBtnCommonAttack);



			CCLabelBMFont* pCommonAttackFont = CCLabelBMFont::create("1","fonts/mhp_num.fnt");
			pCommonAttackFont->setPosition(pBtnCommon->getPosition());
			this->addChild(pCommonAttackFont,enZOrderFront,enTagCommonAttackFont);

			CCSprite * pCommon3 = CCSprite::create("gameui/skill_common.png");
			CC_BREAK_IF(pCommon3==NULL);
			pCommon3->setColor(ccRED);
			pCommon3->setOpacity(100.f);
			
			//创建普通攻击CD
			CCProgressTimer* pProgressCommonAttackCD = CCProgressTimer::create(pCommon3);
			CC_BREAK_IF(pProgressCommonAttackCD==NULL);
			pProgressCommonAttackCD->setType(kCCProgressTimerTypeRadial);
			pProgressCommonAttackCD->setMidpoint(ccp(0.5f,0.5f));
			pProgressCommonAttackCD->setPercentage(0.f);
			pProgressCommonAttackCD->setPosition(pBtnCommon->getPosition());
			this->addChild(pProgressCommonAttackCD,enZOrderFront+1,enTagCommonAttackCD);

			//创建技能按钮
			for (int i=enTagBtnSkill1;i<=enTagBtnSkill5;i++)
			{
				char szName[NAME_LEN] = {0};

				int skilltemp = -1;
				if(i==enTagBtnSkill1){
					skilltemp = m_nSkill_1_ID;
				}else if(i==enTagBtnSkill2){
					skilltemp = m_nSkill_2_ID;
				}else if(i==enTagBtnSkill3){
					skilltemp = m_nSkill_3_ID;
				}else if(i==enTagBtnSkill4){
					skilltemp = m_nSkill_4_ID;
				}else if(i==enTagBtnSkill5){
					skilltemp = m_nSkill_5_ID;
				}

				if(skilltemp==-1){
					continue;
				}

				sprintf(szName,"Skill/r%d_s%d.png",pPro->GetRoleID(),skilltemp);

				CCSprite * pSpr_n = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_n==NULL);
				CCSprite * pSpr_p = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_p==NULL);;
				pSpr_p->setColor(ccBLUE);
				CCSprite * pSpr_d = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_d==NULL);
				pSpr_d->setOpacity(150.f);
				CCSprite * pSpr_CD = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_CD==NULL);
				pSpr_CD->setColor(ccRED);

				//创建技能按钮
				CCMenuItemSprite * pBtn = CCMenuItemSprite::create(pSpr_n,pSpr_p,pSpr_d,this,menu_selector(CNFRockerLayer::OnBtnCallBack));
				CC_BREAK_IF(pBtn==NULL);
				pMenu->addChild(pBtn,enZOrderFront,i);
				if(i==enTagBtnSkill1)		pBtn->setPosition(ccp(pBtnCommon->getPositionX()+10,pBtnCommon->getPositionY()+90));
				else if(i==enTagBtnSkill2)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()-110,pBtnCommon->getPositionY()-5));
				else if(i==enTagBtnSkill3)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()-70,pBtnCommon->getPositionY()+70));
				else if(i==enTagBtnSkill4)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()-200,pBtnCommon->getPositionY()-5));
				else if(i==enTagBtnSkill5)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()+10,pBtnCommon->getPositionY()+170));

				//创建技能CD
				CCProgressTimer* pProgress = CCProgressTimer::create(pSpr_p);
				CC_BREAK_IF(pProgress==NULL);
				pProgress->setType(kCCProgressTimerTypeRadial);
				pProgress->setMidpoint(ccp(0.5f,0.5f));
				pProgress->setPercentage(0.f);
				pProgress->setPosition(pBtn->getPosition());
				this->addChild(pProgress,enZOrderFront+1,i+100);		//技能CD标签 = 技能标签 + 100

				//创建公共CD
				CCProgressTimer* pProgressCD = CCProgressTimer::create(pSpr_CD);
				CC_BREAK_IF(pProgressCD==NULL);
				pProgressCD->setType(kCCProgressTimerTypeRadial);
				pProgressCD->setMidpoint(ccp(0.5f,0.5f));
				pProgressCD->setPercentage(0.f);
				pProgressCD->setPosition(pBtn->getPosition());
				this->addChild(pProgressCD,enZOrderFront+2,i+200);		//技能CD标签 = 技能标签 + 200
				pProgressCD->setVisible(false);
			}
		}
		

		//更新函数
		schedule(schedule_selector(CNFRockerLayer::update));

		return true;
	} while (false);
	CCLog("Fun CNFRockerLayer::InitLayer Error!");
	return false;
}
开发者ID:baidang201,项目名称:NarutoFight,代码行数:101,代码来源:NFRocker.cpp


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