本文整理汇总了C++中CCMenuItemSprite::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemSprite::getPosition方法的具体用法?C++ CCMenuItemSprite::getPosition怎么用?C++ CCMenuItemSprite::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemSprite
的用法示例。
在下文中一共展示了CCMenuItemSprite::getPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool ProceedController::init(){
if (!CCLayer::init()) {
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
//暂停按钮
CCMenuItemSprite *pause = this->instanceButton("pause1.png", "pause2.png", menu_selector(ProceedController::gamePauseFunc));
pause->setScale(1.5f);
pause->setPosition(ccp(size.width - pause->getContentSize().width,
size.height - pause->getContentSize().height));
//跳跃按钮
CCMenuItemSprite *jump = this->instanceButton("control_btn1.png", "control_btn2.png", menu_selector(ProceedController::gameJumpFunc));
jump->setScale(1.6f);
jump->setPosition(ccp(size.width - jump->getContentSize().width - 50, 100));
//fever按钮
CCMenuItemSprite *fever = this->instanceButton("Fever_1_1.png", "Fever_1_1.png",menu_selector(ProceedController::gameFeverFunc));
fever->setScale(1.5f);
fever->setOpacity(0.0f);
fever->setPosition(ccp(jump->getPosition().x - fever->getContentSize().width * 2.0,
jump->getPosition().y));
CCMenu *menu = CCMenu::create(pause,jump,fever,NULL);
menu->setPosition(0, 0);
this->addChild(menu,80);
return true;
}
示例2: InitLayer
bool CNFServerChangeLayer::InitLayer(int nCurrentServerID,int nServerTotalNum)
{
do
{
//初始化父类
CC_BREAK_IF(CCLayer::init()==false);
m_nCurrentServerID = nCurrentServerID;
/************************************************************************/
/* 背景图片 */
/************************************************************************/
//创建背景
CCSprite * pBg = CCSprite::create("ui/serverselect_bg.png");
CC_BREAK_IF(pBg==NULL);
pBg->setPosition(SCREEN_CENTER);
pBg->setScaleX( (float)CCDirector::sharedDirector()->getWinSize().width/(float)pBg->getContentSize().width );
addChild(pBg,enZOrderBack);
//创建上次登录图片
CCSprite * pBg1 = CCSprite::create("ui/serverselect_title_1.png");
CC_BREAK_IF(pBg1==NULL);
pBg1->setPosition(ccp(150+_NF_SCREEN_WIDTH_DIS_,420));
addChild(pBg1,enZOrderBack);
//创建全服务器图片
CCSprite * pBg2 = CCSprite::create("ui/serverselect_title_2.png");
CC_BREAK_IF(pBg2==NULL);
pBg2->setPosition(ccp(160+_NF_SCREEN_WIDTH_DIS_,300));
addChild(pBg2,enZOrderBack);
/************************************************************************/
/* 创建按钮 */
/************************************************************************/
CCMenu * pMenu = CCMenu::create();
CC_BREAK_IF(pMenu==NULL);
pMenu->setPosition(CCPointZero);
addChild(pMenu,enZOrderFront);
//创建返回按钮
//CCMenuItemSprite * pBtnBack = CCMenuItemSprite::create(
// CCSprite::create("ui/serverselect_btn_back_n.png"),
// CCSprite::create("ui/serverselect_btn_back_p.png"),
// this,
// menu_selector(CNFServerChangeLayer::OnBtnCallBack));
//CC_BREAK_IF(pBtnBack==NULL);
//pBtnBack->setPosition(ccp(SCREEN_WIDTH - 30,SCREEN_HEIGHT-30));
//pMenu->addChild(pBtnBack,enZOrderFront);
//创建当前服务器按钮
CCMenuItemSprite * pBtnCurrentServer = CCMenuItemSprite::create(
CCSprite::create("ui/btn_enter_n.png"),
CCSprite::create("ui/btn_enter_p.png"),
this,
menu_selector(CNFServerChangeLayer::OnBtnCallBack));
CC_BREAK_IF(pBtnCurrentServer==NULL);
pBtnCurrentServer->setPosition(ccp(190+_NF_SCREEN_WIDTH_DIS_,380));
pMenu->addChild(pBtnCurrentServer,enZOrderFront);
//创建左侧按钮
CCMenuItemSprite * pBtnLeft = CCMenuItemSprite::create(
CCSprite::create("ui/serverselect_btn_back_n.png"),
CCSprite::create("ui/serverselect_btn_back_p.png"),
this,
menu_selector(CNFServerChangeLayer::OnBtnLeftMove));
CC_BREAK_IF(pBtnLeft==NULL);
pBtnLeft->setPosition(ccp(50+_NF_SCREEN_WIDTH_DIS_,150));
pMenu->addChild(pBtnLeft,enZOrderFront);
//创建右侧按钮
CCMenuItemSprite * pBtnRight = CCMenuItemSprite::create(
CCSprite::create("ui/serverselect_btn_back_n.png"),
CCSprite::create("ui/serverselect_btn_back_p.png"),
this,
menu_selector(CNFServerChangeLayer::OnBtnRightMove));
CC_BREAK_IF(pBtnRight==NULL);
pBtnRight->setPosition(ccp(SCREEN_WIDTH-_NF_SCREEN_WIDTH_DIS_-50,150));
pMenu->addChild(pBtnRight,enZOrderFront);
/************************************************************************/
/* 创建label */
/************************************************************************/
CCDictionary *pDicLang = CCDictionary::createWithContentsOfFile("ui_xml/serverselect_xml.xml");
CC_BREAK_IF(pDicLang==NULL);
//服务器名称label
CCString *pStrServerName = dynamic_cast<CCString*>(pDicLang->objectForKey("server_name"));
char szName[NAME_LEN] = {0};
sprintf(szName,pStrServerName->m_sString.c_str(),nCurrentServerID);
CCLabelTTF * pLabelServerName = CCLabelTTF::create(szName,"Arial",20);
CC_BREAK_IF(pLabelServerName==NULL);
pLabelServerName->setPosition(pBtnCurrentServer->getPosition());
addChild(pLabelServerName,enZOrderFront);
/************************************************************************/
/* 创建滑动层 */
/************************************************************************/
//创建滑动层
CNFServerChangeScrollLayer * pLayer = CNFServerChangeScrollLayer::CreateLayer(nServerTotalNum); //Item数组,x轴起始位置
//.........这里部分代码省略.........
示例3: setDimensions
//.........这里部分代码省略.........
}
m_highlightSp = CCSprite::create("pTabBarSelectedHighlight.png");
{
m_practiceSprite = CCSprite::create("pPencilIcon.png");
CCSprite * aSprite = m_practiceSprite;
aSprite->setPosition(s11Position5_macro(aSprite));
this->addChild(aSprite,100);
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
m_practiceItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S11PrepareRes::menuselect));
CCMenuItemSprite *aItem = m_practiceItem ;
aItem->setTag(2);
aItem->setPosition(s11Position5_macro(aItem));
aItem->setContentSize(m_highlightSp->getContentSize());
_menu ->addChild(aItem,100);
m_touchedItem = m_practiceItem;
m_practiceLabel = CCLabelTTF::create(s11Str1_macro,s11FontName_macro,s11FontSize_macro);
CCLabelTTF* pLabel = m_practiceLabel;
pLabel->setColor(s11White_macro);
pLabel->setAnchorPoint(ccp(0.5,1.0));
pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11));
this->addChild(pLabel, 100);
}
{
m_prepareSprite = CCSprite::create("pDocumentIconActive.png");
CCSprite * aSprite = m_prepareSprite;
aSprite->setPosition(s11Position6_macro(aSprite));
this->addChild(aSprite,100);
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
m_prepareItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S11PrepareRes::menuselect));
CCMenuItemSprite *aItem = m_prepareItem ;
aItem->setTag(3);
aItem->setPosition(s11Position6_macro(aItem));
aItem->setContentSize(m_highlightSp->getContentSize());
_menu ->addChild(aItem,100);
m_prepareLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11FontSize_macro);
CCLabelTTF* pLabel = m_prepareLabel;
pLabel->setColor(s11Blue_macro);
pLabel->setAnchorPoint(ccp(0.5,1.0));
pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11) );
this->addChild(pLabel, 100);
示例4: getItemContentByIndex
BaseSprite* MainLayerHerosBaseBody::getItemContentByIndex(unsigned int index)
{
BaseSprite* bg = BaseSprite::create("duiwu_yingxiong_bg.png");
bg->setPosition(ccp(bg->getContentSize().width/2,bg->getContentSize().height/2));
//图片
{
ImageData data = ImageManager::getManager()->getImageData_ProfessionHead((Profession)mHerosVec[index]->getActorType());
CCLOG("----------------->%s",data.getCurrentImageFile().c_str());
BaseSprite *sprite = BaseSprite::create( data.getCurrentImageFile());
BaseSprite *sprite2 = BaseSprite::create( data.getCurrentImageFile());
BaseSprite *sprite3 = BaseSprite::create( data.getCurrentImageFile());
CCMenuItemSprite* heroItem = CCMenuItemSprite::create(sprite, sprite2, sprite3, this, menu_selector(MainLayerHerosBaseBody::menuItemClicked_heroImg));
CCMenu* menu = CCMenu::create(heroItem, NULL);
bg->addChild(menu, 0, TAG_BaseBody_TABLE_HERO_IMG);
heroItem->setPosition(ccp(74, bg->getContentSize().height/2));
menu->setPosition(CCPointZero);
BaseSprite *biankuang = BaseSprite::create("renxing_renwu_touxiang_select.png");
bg->addChild(biankuang, 1);
biankuang->setPosition(heroItem->getPosition());
BaseSprite *item = NULL;
Profession iType = (Profession)mHerosVec[index]->getActorType();
if (iType == Profession_Yemanren)
{
item = BaseSprite::create("touxiang_jiaobiao_3.png");
}
else if (iType == Profession_Chike)
{
item = BaseSprite::create("touxiang_jiaobiao_2.png");
}
else if (iType == Profession_Fashi)
{
item = BaseSprite::create("touxiang_jiaobiao_1.png");
}
else if (iType == Profession_Qishi)
{
item = BaseSprite::create("touxiang_jiaobiao_3.png");
}
else if (iType == Profession_ShenJianShou)
{
item = BaseSprite::create("touxiang_jiaobiao_4.png");
}
else if (iType == Profession_MiShu)
{
item = BaseSprite::create("touxiang_jiaobiao_1.png");
}
else if (iType == Profession_WuSeng)
{
item = BaseSprite::create("touxiang_jiaobiao_5.png");
}
else if (iType == Profession_YouXia)
{
item = BaseSprite::create("touxiang_jiaobiao_2.png");
}
else if (iType == Profession_LieShou)
{
item = BaseSprite::create("touxiang_jiaobiao_4.png");
}
else if (iType == Profession_WuShi)
{
item = BaseSprite::create("touxiang_jiaobiao_6.png");
}
if (item)
{
item->setAnchorPoint(ccp(1, 0));
biankuang->addChild(item);
item->setPosition(ccp(biankuang->getContentSize().width, 0));
}
}
//name
HeroFixedPro info = BaseActorPropertyParser::getParser()->getExtraProerty((Profession)mHerosVec[index]->getActorType());
LF::lable(bg, info.nameInChinese,ccp(140, 106),22,fontStr_kaiti)->setTag(TAG_BaseBody_LABLE_NAME);
// 英雄介绍
{
Profession profId = mHerosVec[index]->getActorType();
CCLabelTTF *directionLabel = CCLabelTTF::create(getHeroDirectionByProfessionId(profId).c_str(), fontStr_kaiti, 20, CCSize(380, 0), kCCTextAlignmentLeft);
bg->addChild(directionLabel, 1, Tag_Label_HeroDirection);
directionLabel->setColor(ccc3(165, 125, 76));
directionLabel->setAnchorPoint(ccp(0, 1));
directionLabel->setPosition(ccp(140, 94));
}
if (mFlag == 1)
{
CCMenuItemImage* chose = CCMenuItemImage::create(
"duiwu_yingxiong_weixuanzhong.png"
, "duiwu_yingxiong_weixuanzhong.png"
, this, menu_selector(MainLayerHerosBaseBody::menuItemClicked_choseHero));
chose->setPosition(558, 83);
CCMenu* menu = CCMenu::create(chose, NULL);
menu->setPosition(CCPointZero);
bg->addChild(menu, 0, TAG_Menu);
CCSprite* unlock = CCSprite::create("duiwu_yingxiong_unlock.png", CCRect(0, 0, 610, 129));
//.........这里部分代码省略.........
示例5: init
bool MultiplayerLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! OverlayBase::init());
CCSize size = CCDirector::sharedDirector()->getWinSize();
int leftSpace = 100;
_opponentType = kHuman;
CCMenuItemSprite* hItem = createMenuItemSprite((char*)"btnHotSeat128x128.png",
(char*)"btnHotSeatPressed.png",
menu_selector(MultiplayerLayer::onHotSeat));
CCMenuItemSprite* onlineItem = createMenuItemSprite((char*)"btnOnlineGame128x128.png",
(char*)"btnOnlineGamePressed.png",
menu_selector(MultiplayerLayer::onOnlineGame));
CCMenu* menu = CCMenu::create(hItem, onlineItem, NULL);
menu->alignItemsVertically();
menu->setPosition(ccp(leftSpace, size.height - 2 * leftSpace));
addChild(menu, 1);
if (!sgl_ConnectionManager.getRoomNumber().empty())
{
CCMenuItemSprite* onlineReconnectItem = createMenuItemSprite((char*)"btnOnlineGameReconnect.png",
(char*)"btnOnlineGamePressed.png",
menu_selector(MultiplayerLayer::onOnlineGame));
menu->cocos2d::CCNode::addChild(onlineReconnectItem);
}
float menuLimit = hItem->getPosition().x + hItem->boundingBox().size.width + 20;
CCLabelTTF* lH = new CCLabelTTF();
lH->initWithString("Hot seat", S_F_TYPE.c_str(), 32);
lH->setPosition(ccp(menuLimit, hItem->getPosition().y));
lH->setAnchorPoint(ccp(0,0));
hItem->addChild(lH);
CCLabelTTF* lO = new CCLabelTTF();
lO->initWithString("Random online game", S_F_TYPE.c_str(), 32);
lO->setPosition(ccp(menuLimit, hItem->getPosition().y));
lO->setAnchorPoint(ccp(0,0));
onlineItem->addChild(lO);
//Cancel - Go Menu
CCMenuItemSprite* mRightArrow =
sgl_SpriteFactory.createMenuItemSprite("btnArrow_Back128x128.png", "btnArrow_Back128x128Pressed.png", menu_selector(MultiplayerLayer::onQuit), this);
CCMenu* menuReturn = CCMenu::create(mRightArrow, NULL);
CCMenuItemSprite* mLeftArrow =
sgl_SpriteFactory.createMenuItemSprite("btnArrow128x128.png", "btnArrow128x128Pressed.png", menu_selector(MultiplayerLayer::onConnect), this);
CCMenu* mStartGame = CCMenu::create(mLeftArrow, NULL);
menuReturn->setPosition(leftSpace, 150);
mStartGame->setPosition(size.width - leftSpace - mLeftArrow->boundingBox().size.width * 0.5f, 150);
addChild(mStartGame);
addChild(menuReturn);
_connectionStatus = CCLabelTTF::create("", S_F_TYPE.c_str(), 32);
_connectionStatus->setPosition(ccp(size.width/2, 150));
this->addChild(_connectionStatus);
bRet = true;
} while (0);
return bRet;
}
示例6: InitLayer
bool CNFRockerLayer::InitLayer(CNF3DWorldLayer * pLayer,int nStageID)
{
do
{
//初始化父类
CC_BREAK_IF(CCLayerColor::initWithColor(ccc4(255,0,0,50))==false);
//注册
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,-1,false);
//设置层大小
setContentSize(CCSizeMake(200,200));//(CCSizeMake(SCREEN_WIDTH*0.5f,SCREEN_HEIGHT));
m_p3DLayer = pLayer;
m_bIsTouching = false;
m_bIsPublicCD = false;
m_fRockerSpeed = _NF_ROCKER_SPEED_; //摇杆的移动速度
m_fRockerMaxDis = _NF_ROCKER_MAX_DIS_; //摇杆最大偏移量
m_nStageID = nStageID;
//主角技能ID
CNFProtagonist * pPro = dynamic_cast<CNFProtagonist *>(pLayer->getChildByTag(enTagProtagonist));
CC_BREAK_IF(pPro==NULL);
m_nSkill_1_ID = pPro->GetSkillInfo_1().nSkill_SkillItemID;
m_nSkill_2_ID = pPro->GetSkillInfo_2().nSkill_SkillItemID;
m_nSkill_3_ID = pPro->GetSkillInfo_3().nSkill_SkillItemID;
m_nSkill_4_ID = pPro->GetSkillInfo_4().nSkill_SkillItemID;
m_nSkill_5_ID = pPro->GetSkillInfo_5().nSkill_SkillItemID;
//创建摇杆背景
CCSprite * pRockerBg = CCSprite::create("gameui/rocker_bg.png");
CC_BREAK_IF(pRockerBg==NULL);
//pRockerBg->setScale(2.5f);
pRockerBg->setPosition(ccp(100,100));
addChild(pRockerBg,enZOrderFront,enTagRockerBg);
pRockerBg->setOpacity(100.f);
//创建摇杆
CCSprite * pRocker = CCSprite::create("gameui/rocker_ball.png");
CC_BREAK_IF(pRocker==NULL);
pRocker->setPosition(pRockerBg->getPosition());
addChild(pRocker,enZOrderFront+1,enTagRocker);
pRocker->setOpacity(100.f);
//若为副本,则创建按钮
if (m_nStageID >= _NF_TOWN_OR_BATTLE_ID_ && m_nStageID <_NF_TOWN_FB_ID_)
{
/************************************************************************/
/* 创建按钮 */
/************************************************************************/
//创建菜单
CCMenu * pMenu = CCMenu::create();
CC_BREAK_IF(pMenu==NULL);
pMenu->setPosition(CCPointZero);
addChild(pMenu,enZOrderFront,enTagMenu);
//创建普通攻击按钮
CCSprite * pCommon1 = CCSprite::create("gameui/skill_common.png");
CC_BREAK_IF(pCommon1==NULL);
CCSprite * pCommon2 = CCSprite::create("gameui/skill_common.png");
CC_BREAK_IF(pCommon2==NULL);
pCommon2->setOpacity(150.f);
CCMenuItemSprite * pBtnCommon = CCMenuItemSprite::create(pCommon1,pCommon2,this,menu_selector(CNFRockerLayer::OnBtnCallBack));
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){
//.........这里部分代码省略.........