本文整理汇总了C++中CCMenuItemImage::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::getPositionX方法的具体用法?C++ CCMenuItemImage::getPositionX怎么用?C++ CCMenuItemImage::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::getPositionX方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveBlock
void HelloWorld::moveBlock()
{
int pPillar = 20; // prior pillar (block-containing pillar)
int newTopBlock = 20;
CCMenuItemImage* pillar = ((CCMenuItemImage*)(this->getChildByTag(selectedPillar)->getChildByTag(selectedPillar)));
CCMenuItemImage* block = ((CCMenuItemImage*)(this->getChildByTag(selectedBlock)->getChildByTag(selectedBlock)));
// disable pillars, set to default
for (int i=0 ; i<3 ; i++)
{
//((CCMenuItemImage*)((this->getChildByTag(i))->getChildByTag(i)))->setEnabled(false);
//((CCMenuItemImage*)((this->getChildByTag(i))->getChildByTag(i)))->setOpacity(255);
// determine block-containing pillar via boundingBox containsPoint fxn
if (((CCMenuItemImage*)(this->getChildByTag(i)->getChildByTag(i)))->boundingBox().containsPoint(block->getPosition()) == true)
{
//CCLog("block-containing pillar is %i",i);
pPillar = i;
break;
}
}
// loop through blocks for belowBlock
float belowBlock = block->getPositionY() - bHeight;
for (int x=3 ; x<10 ; x++)
{
if (((CCMenuItemImage*)((this->getChildByTag(x))->getChildByTag(x)))->boundingBox().containsPoint(ccp(block->getPositionX(),belowBlock)) == true)
{
//CCLog("belowBlock is block tag %i",x);
newTopBlock = x;
break;
}
}
block->setPosition(ccp(pillar->getPositionX(),(-150+(bHeight*numBlock[selectedPillar]))));
// add to number of blocks on selectedPillar
numBlock[selectedPillar]++;
//CCLog("pillar %i has %i blocks",selectedPillar,numBlock[selectedPillar]);
// subtract number of blocks from priorPillar
numBlock[pPillar]--;
//CCLog("pillar %i has %i blocks",pPillar,numBlock[pPillar]);
// set topBlock for selectedPillar
topBlock[selectedPillar] = selectedBlock;
//CCLog("pillar %i's top block is tag %i",selectedPillar,selectedBlock);
// set topBlock for priorPillar
topBlock[pPillar] = newTopBlock;
//CCLog("pillar %i's top block is tag %i",pPillar,newTopBlock);
}
示例2: addWinMenu
// Add button menu to win layer.
void GameEndLayer::addWinMenu()
{
CCMenuItemImage* replay = CCMenuItemImage::create(nameOfRestartNormal, nameOfRestartSelect, this,
menu_selector(GameEndLayer::onReplay));
replay->setScale(1.5f);
CCMenuItemImage* levels = CCMenuItemImage::create(nameOfSelectLevelNormal, nameOfSelectLevelSelect, this,
menu_selector(GameEndLayer::onLevels));
levels->setScale(1.5f);
CCMenuItemImage* next = CCMenuItemImage::create(nextButtonNormal, nextButtonSelect, this,
menu_selector(GameEndLayer::onNext));
next->setScale(1.5f);
CCMenu* menu = CCMenu::create(replay, levels, next, NULL);
// Padding the items.
menu->alignItemsHorizontallyWithPadding(20);
menu->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2 - levels->getPositionX(),
CCDirector::sharedDirector()->getWinSize().height / 4));
this->addChild(menu, 2);
}
示例3: ccp
CCMenuItemImage * GafFeatures::addBtn(const char * text, float px, float py, SEL_MenuHandler handler, float k)
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage *res = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
handler );
res->setPosition( ccp(size.width * px, size.height * py) );
res->setScale(k);
CCLabelTTF* pLabel = CCLabelTTF::create(text, "Thonburi", 34);
pLabel->setColor(ccc3(0, 0, 255));
pLabel->setAnchorPoint(CCPoint(1, 0.5));
pLabel->setScale(k);
pLabel->setPosition( ccp(res->getPositionX() - res->getContentSize().width * k * 0.5, res->getPositionY()) );
addChild(pLabel, 100000);
return res;
}
示例4: init
bool MainMenuLayer::init()
{
if (CCLayerColor::initWithColor(ccc4(255, 255, 255, 255))) {
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pStartGameItem = CCMenuItemImage::create(
"button-newgame.png",
"button-newgame-sel.png",
this,
menu_selector(MainMenuLayer::menuStartGameCallback));
CCMenuItemImage *pExitItem = CCMenuItemImage::create(
"button-exit.png",
"button-exit-sel.png",
this,
menu_selector(MainMenuLayer::menuExitCallback));
// Place the menu item bottom-right conner.
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
int v_space = 5;
pExitItem->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height * 1 / 3));
pStartGameItem->setPosition(ccp(pExitItem->getPositionX(),
pExitItem->getPositionY() +
pExitItem->getContentSize().height / 2 +
pStartGameItem->getContentSize().height / 2 +
v_space));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pStartGameItem, pExitItem, NULL);
pMenu->setPosition(CCPointZero);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, 1);
// loading best score
HelloWorld::max_points_result =
CCUserDefault::sharedUserDefault()->getIntegerForKey(
"max_points_result");
// Max points label
v_space = 10;
std::stringstream strs;
strs << HelloWorld::max_points_result;
std::string temp_str = strs.str();
char const* pchar = temp_str.c_str();
max_points_label = CCLabelTTF::create(pchar,
"Artial", 20);
max_points_label->retain();
max_points_label->setColor(ccc3(0, 255, 0));
max_points_label->setPosition(
ccp(pExitItem->getPositionX(),
pStartGameItem->getPositionY() +
pStartGameItem->getContentSize().height / 2 +
max_points_label->getFontSize() / 2 + v_space));
this->addChild(max_points_label);
// Above max points label
v_space = 3;
CCLabelTTF* max_points_above_label = CCLabelTTF::create("Best Score",
"Artial", 18);
max_points_above_label->retain();
max_points_above_label->setColor(ccc3(0, 0, 0));
max_points_above_label->setPosition(
ccp(pExitItem->getPositionX(),
max_points_label->getPositionY() +
max_points_label->getContentSize().height / 2 +
max_points_above_label->getFontSize() / 2 + v_space));
this->addChild(max_points_above_label);
}
else {
return false;
}
}
示例5: setSystemMail
void MailInfoListLayer::setSystemMail(Email mail)
{
//CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,-132,true);
ListMenu *menu = ListMenu::create();
menu->setPosition(CCPointZero);
menu->setAnchorPoint(CCPointZero);
menu->setContentSize(this->getContentSize());
addChild(menu);
m_mMenu = menu;
//m_mMenu->runAction(CCCallFuncND::create(this, callfuncND_selector(MailInfoListLayer::changeMenuPriority_callfuncND), (void*)(-133)));
m_eEmail = mail;
sortMail(mail);
int count = 0;
int height = m_nHeight;
int width = count * 100;
m_nWidth = width;
count = 0;
int side = 50;
int bWidth = 0;
int _width = 0;
int pos_x = 0;
for (map<string,string>::iterator iter = m_lThingsList.begin(); iter != m_lThingsList.end() ; iter ++)
{
CCSprite *cailiaoSpr = CCSprite::create("daoju_kuang_bg.png");
cailiaoSpr->setScale(0.7f);
bWidth = cailiaoSpr->getContentSize().width * cailiaoSpr->getScaleX();
cailiaoSpr->setPosition(ccp(count * bWidth + ( side * ( count * 2 + 1 ) ) + bWidth / 2 ,height - cailiaoSpr->getContentSize().height * cailiaoSpr->getScaleY() / 2 - 5));
addChild(cailiaoSpr);
CCSprite *daojuSpr = CCSprite::create(iter->first.c_str());
daojuSpr->setScale(0.7f);
bWidth = daojuSpr->getContentSize().width * cailiaoSpr->getScaleX();
daojuSpr->setPosition(ccp(cailiaoSpr->getContentSize().width / 2, cailiaoSpr->getContentSize().height / 2));
cailiaoSpr->addChild(daojuSpr);
CCLabelTTF *nameTTF = CCLabelTTF::create(iter->second.c_str(),fontStr_kaiti,25.0f);
nameTTF->setPosition(ccp(cailiaoSpr->getPositionX(),nameTTF->getContentSize().height / 2 + 5));
addChild(nameTTF);
nameTTF->setColor(ccWHITE);
_width += cailiaoSpr->getPositionX() - pos_x;
pos_x = cailiaoSpr->getPositionX();
count ++;
}
_width += bWidth / 2 + side;
for (vector<Flat_DuanzaoGroupZBInfo>::iterator iter = mail.equipVec.begin(); iter != mail.equipVec.end() ; iter ++)
{
CCLabelTTF *nameTTF = CCLabelTTF::create(iter->zhuangbei_name.c_str(),fontStr_kaiti,25.0f);
nameTTF->setPosition(ccp(count * bWidth + ( side * ( count * 2 + 1 ) ) + bWidth / 2 + nameTTF->getContentSize().height / 2 ,nameTTF->getContentSize().height / 2 + 20));
addChild(nameTTF);
nameTTF->setColor(ccWHITE);
//string nameTemp = CS::getItemName(iter->zb_group_id) + LFStrings::getValue("zhi") + LFStrings::getValue("suipian") + getStrByInt(iter->suipian_id);
string equipfile = iter->zhuangbei_pic;
equipfile = "minute_" + equipfile + ".png";
m_lThingsList.insert(map<string,string>::value_type(equipfile,iter->zhuangbei_name));
string diwenStr = ImageManager::getManager()->getImageData_DiWen_WithBianKuang(iter->zhuangbei_colour);
CCMenuItemImage *eqDiwenImg = CCMenuItemImage::create(diwenStr.c_str(), diwenStr.c_str(), this,
menu_selector(MailInfoListLayer::menuItemClicked_Equip));
m_mMenu->addChild(eqDiwenImg);
eqDiwenImg->setTag(iter->zb_group_id);
eqDiwenImg->setScale(0.8f);
bWidth = eqDiwenImg->getContentSize().width * eqDiwenImg->getScaleX();
eqDiwenImg->setPosition(ccp( nameTTF->getPositionX(),nameTTF->getPositionY() + nameTTF->getContentSize().height / 2 + eqDiwenImg->getContentSize().height / 2 + 5));
CCSprite *daojuSpr = CCSprite::create(equipfile.c_str());
daojuSpr->setScale(0.24f);
bWidth = daojuSpr->getContentSize().width * eqDiwenImg->getScaleX();
daojuSpr->setPosition(ccp(eqDiwenImg->getContentSize().width / 2, eqDiwenImg->getContentSize().height / 2));
eqDiwenImg->addChild(daojuSpr);
/*CCSprite *cailiaoSpr = CCSprite::create("daoju_kuang_bg.png");
cailiaoSpr->setScale(0.7f);
bWidth = cailiaoSpr->getContentSize().width * cailiaoSpr->getScaleX();
cailiaoSpr->setPosition(ccp(count * bWidth + ( side * ( count * 2 + 1 ) ) + bWidth / 2 ,height - cailiaoSpr->getContentSize().height * cailiaoSpr->getScaleY() / 2 - 5));
addChild(cailiaoSpr);*/
_width += eqDiwenImg->getPositionX() - pos_x;
pos_x = eqDiwenImg->getPositionX();
count ++;
}
_width += bWidth / 2 + side;
m_nWidth = _width;
this->setContentSize(CCSizeMake(m_nWidth,m_nHeight));
}
示例6: showItemsNode
void IOSStoreLayer::showItemsNode()
{
int iTotalCount = 1;
int iPrice = 10;
int xcount = 1;
int ycount = 1;
CCSize size = CCSizeMake(120, 190);
if (m_bBaoxiangBuyTenTimes)
{
iTotalCount = 10;
size.width = 820;
size.height = 350;
xcount = 5;
ycount = 2;
iPrice = 95;
}
iTotalCount = this->getKaiBaoxiangRsqData().size();
if (iTotalCount >= 11)
{
xcount = 6;
}
if (iTotalCount == 2)
{
xcount = 2;
size = CCSizeMake(140*2, 190);
}
IOSStoreLayerScrollView* pView = IOSStoreLayerScrollView::createView(size, iTotalCount, xcount, ycount);
m_pGetItemNode->addChild(pView);
pView->ignoreAnchorPointForPosition(false);
pView->setAnchorPoint(ccp(0.5f, 0.5f));
pView->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2 - 60));
pView->setClickableCreater(pView);
pView->prepareToDisplay();
pView->setTouchEnabled(false);
pView->setTag(getitem_scrollview_tag);
//显示
CCSprite* pSmallbg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_anniu_zaikaishici_fujia.png").c_str());
m_pGetItemNode->addChild(pSmallbg, 1);
pSmallbg->setPosition(ccp(200, 100));
//添加菜单
CCMenu* pMenu = CCMenu::create();
pMenu->setPosition(CCPointZero);
m_pGetItemNode->addChild(pMenu, 2);
//再开按钮
CCMenuItemImage* pItem = NULL;
int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
if (m_bBaoxiangBuyTenTimes)
{
pItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pItem->setTag(buy_ten_again);
}
else
{
pItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pItem->setTag(buy_one_again);
}
pItem->setPosition(ccp(pSmallbg->getPositionX() + pSmallbg->getContentSize().width/2 + pItem->getContentSize().width/2 - 30,
pSmallbg->getPositionY()));
pMenu->addChild(pItem);
//星星数量
CCLabelAtlas* lable = CCLabelAtlas::create(
"0123456789",
ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
30, 47,//24
'0');
m_pGetItemNode->addChild(lable, 1, star_count_str_tag);
lable->setAnchorPoint(ccp(0, 0.5));
lable->setScale(0.6f);
int iCount = 10;
if (m_bBaoxiangBuyTenTimes)
{
iCount = 95;
}
char charStarCount[10] = {};
sprintf(charStarCount, "%d", iCount);
lable->setString(charStarCount);
lable->setPosition(ccp(pItem->getPositionX()-pItem->getContentSize().width/2-lable->getContentSize().width/2 - 40, pSmallbg->getPositionY() - 3));
//右边星星图标
CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
m_pGetItemNode->addChild(pXingxing, 1);
pXingxing->setPosition(ccp(lable->getPositionX() - 30, pSmallbg->getPositionY()));
//星星数不够时,只显示确定按钮
//确定按钮
CCMenuItemImage* pOKItem = CCMenuItemImage::create(
//.........这里部分代码省略.........
示例7: selectPillar
void HelloWorld::selectPillar(CCObject* target)
{
bool bTopBlock = true;
float topBlockSize;
float selectedBlockSize;
// set all pillar colors to default
for (int i=0 ; i<3 ; i++)
{
((CCMenuItemImage*)((this->getChildByTag(i))->getChildByTag(i)))->setOpacity(255);
}
// set selected pillar
CCMenuItemImage* pillar = (CCMenuItemImage*)(target);
selectedPillar = pillar->getTag();
//pillar->setOpacity(140);
//CCLog("selectedPillar is %i",selectedPillar);
if (topBlock[selectedPillar] == 20)
{
topBlockSize = 0;
}
else
{
topBlockSize = ((CCMenuItemImage*)(this->getChildByTag(topBlock[selectedPillar])->getChildByTag(topBlock[selectedPillar])))->getScaleX();
}
selectedBlockSize = ((CCMenuItemImage*)(this->getChildByTag(selectedBlock)->getChildByTag(selectedBlock)))->getScaleX();
// if selected block size is < top block on pillar OR no block on pillar OR no block above it, run move block fxn
CCMenuItemImage* block = ((CCMenuItemImage*)(this->getChildByTag(selectedBlock)->getChildByTag(selectedBlock)));
float aboveBlock = block->getPositionY() + bHeight;
for (int x=3 ; x<10 ; x++)
{
if (((CCMenuItemImage*)(this->getChildByTag(x)->getChildByTag(x)))->boundingBox().containsPoint(ccp(block->getPositionX(),aboveBlock)) == true)
{
//CCLog("block exists above selected block");
bTopBlock = false;
break;
}
}
//CCLog("topBlockSize is %f\nselectedBlockSize is %f",topBlockSize,selectedBlockSize);
if ((numBlock[selectedPillar] == 0) || (selectedBlockSize < topBlockSize))
{
if (bTopBlock == true)
moveBlock();
}
// winning condition - 7 blocks,top block is tag 9
for (int y=1 ; y<3 ; y++)
{
if (numBlock[y] == 7)
{
if (topBlock[y] == 9)
{
CCSprite* winMsg = CCSprite::create("/winMsg.png");
winMsg->setPosition(ccp(240,150));
winMsg->setScale(float(.5));
this->addChild(winMsg);
CCMenu* restartM = CCMenu::create();
CCMenuItemImage* restartB = CCMenuItemImage::create("/restartB.png","/restartB.png",this,menu_selector(HelloWorld::restartGame));
(restartB->getSelectedImage())->setScale(.75);
(restartB->getSelectedImage())->setPosition(ccp(restartB->getPositionX()+20,restartB->getPositionY()+20));
restartB->setScale(float(.5));
restartB->setPositionY(-50);
restartM->addChild(restartB);
this->addChild(restartM);
break;
}
}
}
}
示例8:
MainFooterLayer::MainFooterLayer()
{
mFootContainer = BaseSprite::create("zhuye_anniu_bg.png");
addChild(mFootContainer);
CCPoint originPos = CCDirector::sharedDirector()->getVisibleOrigin();
mFootContainer->setPosition(ccp(mWinSize.width/2,originPos.y + mFootContainer->getContentSize().height/2));
//menu
// {
// mMenuItemHome = CCMenuItemImage::create(
// "function_main.png",
// "function_main_select.png",
// this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
// mMenuItemMaoxian = CCMenuItemImage::create(
// "function_adventure.png",
// "function_adventure_select.png",
// this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
// mMenuItemZhuangbei = CCMenuItemImage::create(
// "function_equipment.png",
// "function_equipment_select.png",
// this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
// mMenuItemJinji = CCMenuItemImage::create(
// "function_pk.png",
// "function_pk_select.png",
// this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
// mMenuItemMengyou = CCMenuItemImage::create(
// "function_friend.png",
// "function_friend_select.png",
// this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
// mMenuItemStore = CCMenuItemImage::create(
// "function_shop.png",
// "function_shop_select.png",
// this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
//
//
// mMenu = CCMenu::create(mMenuItemHome, mMenuItemMaoxian, mMenuItemZhuangbei
// , mMenuItemJinji,mMenuItemMengyou , mMenuItemStore, NULL);
// addChild(mMenu,1);
// mMenu->setPosition(CCPointZero);
//
// mMenuItemHome->setPosition(ccp(45+2,50));
// mMenuItemHome->setTag(TAG_MENU_HOME);
//
// mMenuItemMaoxian->setPosition(ccp(45+90+4,50));
// mMenuItemMaoxian->setTag(TAG_MENU_MAOXIAN);
//
// mMenuItemZhuangbei->setPosition(ccp(45+90*2+6,50));
// mMenuItemZhuangbei->setTag(TAG_MENU_ZHUANGBEI);
//
// mMenuItemJinji->setPosition(ccp(640-45-90*2-6,50));
// mMenuItemJinji->setTag(TAG_MENU_JINJI);
//
// mMenuItemMengyou->setPosition(ccp(640-45-90-4,50));
// mMenuItemMengyou->setTag(TAG_MENU_MENGYOU);
//
// mMenuItemStore->setPosition(ccp(640-45-2,50));
// mMenuItemStore->setTag(TAG_MENU_STORE);
// }
{
CCMenuItemImage *itemMaoxian = CCMenuItemImage::create(
"zhuye_anniu_maoxian.png",
"zhuye_anniu_maoxian_select.png",
this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
CCMenuItemImage *itemJingji = CCMenuItemImage::create(
"zhuye_anniu_jingji.png",
"zhuye_anniu_jingji_select.png",
this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
CCMenuItemImage *itemZhuye = CCMenuItemImage::create(
"zhuye_anniu_zhuye_select.png",
"zhuye_anniu_zhuye.png",
this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
CCMenuItemImage *itemHuodong = CCMenuItemImage::create(
"zhuye_anniu_huodong.png",
"zhuye_anniu_huodong_select.png",
this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
CCMenuItemImage *itemShangdian = CCMenuItemImage::create(
"zhuye_anniu_shangdian.png",
"zhuye_anniu_shangdian_select.png",
this,SEL_MenuHandler(&MainFooterLayer::menuItemClicked));
mMenu = CCMenu::create(itemMaoxian, itemShangdian, itemZhuye, itemJingji, itemHuodong, NULL);
mFootContainer->addChild(mMenu,1);
mMenu->setPosition(CCPointZero);
itemZhuye->setPosition(ccp(320, 122-68));
itemZhuye->setTag(TAG_MENU_HOME);
itemJingji->setPosition(ccp(itemZhuye->getPositionX()-itemJingji->getContentSize().width/2-itemZhuye->getContentSize().width/2, 122-68));
itemJingji->setTag(TAG_MENU_JINGJI);
itemMaoxian->setPosition(ccp(itemJingji->getPositionX()-itemJingji->getContentSize().width/2-itemJingji->getContentSize().width/2, 122-68));
itemMaoxian->setTag(TAG_MENU_MAOXIAN);
itemHuodong->setPosition(ccp(itemZhuye->getPositionX()+itemZhuye->getContentSize().width/2+itemHuodong->getContentSize().width/2, 122-68));
itemHuodong->setTag(TAG_MENU_HUODONG);
itemShangdian->setPosition(ccp(itemHuodong->getPositionX()+itemHuodong->getContentSize().width/2+itemShangdian->getContentSize().width/2, 122-68));
itemShangdian->setTag(TAG_MENU_STORE);
//.........这里部分代码省略.........
示例9: initItem
bool ChuanqiduanzaoItem::initItem(BaseActor* info)
{
bool bret = false;
//初始化背景
if (CCSprite::initWithFile("shangdian_chuanqi_bg.png"))
{
bret = true;
}
if (bret)
{
m_Profession_id = info->getCurrentProperty().profession;
//顶部文字显示
CCLabelTTF* pTopTip = CCLabelTTF::create(LFStrings::getValue("ShenBingDuanZao_ShuoMingTiShi").c_str(), fontStr_kaiti, 18);
pTopTip->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height-70));
pTopTip->setColor(fonColor_FaGuang);
this->addChild(pTopTip);
//头像
CCSprite* pIcon = CCSprite::create(this->getIconFileNameByType(info->getActorType()).c_str());
this->addChild(pIcon);
pIcon->setPosition(ccp(this->getContentSize().width/2, 400));
//美术字(英雄类型)
CCSprite* pHeroType = CCSprite::create(this->getHeroTypeFileNameByType(info->getActorType()).c_str());
this->addChild(pHeroType);
pHeroType->setPosition(ccp(this->getContentSize().width/2,
pIcon->getPositionY()-pIcon->getContentSize().height/2-pHeroType->getContentSize().height+2));
//套装名字
string zhuangBeiStr = ChuanqiPool::getPool()->getChuanQiSuitName(info->getActorType());
CCLabelTTF* pName = CCLabelTTF::create(zhuangBeiStr.c_str(), fontStr_kaiti, 20);
pName->setPosition(ccp(this->getContentSize().width/2, 280));
this->addChild(pName);
CCMenu* pMenu = CCMenu::create();
this->addChild(pMenu);
pMenu->setPosition(CCPointZero);
//锻造一次
CCMenuItemImage *yici = CCMenuItemImage::create(
"shangdian_shenbin_anniu_duanzaoyici.png",
"shangdian_shenbin_anniu_duanzaoyici_select.png",
this, menu_selector(ChuanqiduanzaoItem::menuItemClicked_DuanZao));
pMenu->addChild(yici, 0, Tag_MenuItem_Yici);
yici->setPosition(ccp(this->getContentSize().width/2-yici->getContentSize().width/2, 185));
yici->setUserData((void*)info->getActorType());
//锻造十次
CCMenuItemImage *shici = CCMenuItemImage::create(
"shangdian_shenbin_anniu_duanzaoshici.png",
"shangdian_shenbin_anniu_duanzaoshici_select.png",
this, menu_selector(ChuanqiduanzaoItem::menuItemClicked_DuanZao));
pMenu->addChild(shici, 0, Tag_MenuItem_Shici);
shici->setPosition(ccp(this->getContentSize().width/2+yici->getContentSize().width/2, yici->getPositionY()));
shici->setUserData((void*)info->getActorType());
char buf[20];
//锻造一次需要金币
BaseSprite *goldIcon1 = BaseSprite::create("jinbi_tubiao.png");
this->addChild(goldIcon1);
goldIcon1->setScale(0.5f);
goldIcon1->setPosition(ccp(yici->getPositionX()-goldIcon1->getContentSize().width/2, yici->getPositionY()+yici->getContentSize().height/2+goldIcon1->getContentSize().height/2));
sprintf(buf, "%d", 400);
CCLabelTTF *yiciLabel = CCLabelTTF::create(buf, fontStr_BookAntiqua, 20);
this->addChild(yiciLabel);
yiciLabel->setPosition(ccp(goldIcon1->getPositionX()+goldIcon1->getContentSize().width/2*goldIcon1->getScaleX()+yiciLabel->getContentSize().width/2
, goldIcon1->getPositionY()));
//锻造十次需要金币
BaseSprite *goldIcon10 = BaseSprite::create("jinbi_tubiao.png");
this->addChild(goldIcon10);
goldIcon10->setScale(0.5f);
goldIcon10->setPosition(ccp(shici->getPositionX()-goldIcon10->getContentSize().width/2, shici->getPositionY()+shici->getContentSize().height/2+goldIcon10->getContentSize().height/2));
sprintf(buf, "%d", 400*10);
CCLabelTTF *yiciLabel0 = CCLabelTTF::create(buf, fontStr_BookAntiqua, 20);
this->addChild(yiciLabel0);
yiciLabel0->setPosition(ccp(goldIcon10->getPositionX()+goldIcon10->getContentSize().width/2*goldIcon10->getScaleX()+yiciLabel0->getContentSize().width/2
, goldIcon10->getPositionY()));
CCMenuItemImage* pXiaoguo = CCMenuItemImage::create(
"shandian_anniu_taozhuangxiaoguo.png",
"shandian_anniu_taozhuangxiaoguo_select.png",
this, menu_selector(ChuanqiduanzaoItem::menuItemClicked_Xiaoguo)
);
pMenu->addChild(pXiaoguo);
pXiaoguo->setPosition(ccp(this->getContentSize().width/2, pXiaoguo->getContentSize().height/2));
}
return bret;
}