本文整理汇总了C++中BaseSprite::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseSprite::setPosition方法的具体用法?C++ BaseSprite::setPosition怎么用?C++ BaseSprite::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseSprite
的用法示例。
在下文中一共展示了BaseSprite::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
void ZhuangbeiXilianOverOption::onEnter()
{
CCSprite::onEnter();
if (m_nLevel != -1)
{
BaseSprite *bgSpr = BaseSprite::create("zhuangbei_xiangxi_xilian_shuxing.png");
addChild(bgSpr);
this->setContentSize(bgSpr->getContentSize());
BaseSprite *xingxingImg = BaseSprite::create(CCString::createWithFormat("gongming_anniu_%d.png",m_nLevel)->getCString());
bgSpr->addChild(xingxingImg);
xingxingImg->setPosition(ccp(40, bgSpr->getContentSize().height / 2));
xingxingImg->setScale(0.58f);
ZBAttr zb_attr;
zb_attr.attr_type = m_nAtter_type_index;
zb_attr.attr_value = m_nPercent;
string attrStr = GetMoFaShuXing_ByZBAttr(zb_attr, true);
CCLabelTTF *label = CCLabelTTF::create(attrStr.c_str(), fontStr_kaiti, 20);
bgSpr->addChild(label);
label->setColor(ccc3(255,255,255));
label->setPosition(ccp(bgSpr->getContentSize().width / 2, bgSpr->getContentSize().height / 2));
bgSpr->setPosition(ccp(bgSpr->getContentSize().width / 2,bgSpr->getContentSize().height / 2));
if (m_bIsBiger)
{
CCSprite *spr = CCSprite::create("renxing_zhuangbeitisheng.png");
spr->setPosition(ccp(230,this->getContentSize().height / 2));
bgSpr->addChild(spr);
}
if (m_bIsFirst)
{
CCSprite *spr = CCSprite::create("zhuangbei_xiangxi_xilian_shuxing_xiaoguo.png");
spr->setPosition(ccp(this->getContentSize().width / 2,this->getContentSize().height / 2));
bgSpr->addChild(spr);
float time = 0;
float minTime = 0.5f;
float maxTime = 1.2f;
time = CCRANDOM_0_1()*(maxTime - minTime) + minTime;
Blink(spr,time);
}
}
else
{
BaseSprite *xingxingImg = BaseSprite::create("zhuangbei_xiangxi_xilian_shuxing_suoding.png");
addChild(xingxingImg);
xingxingImg->setPosition(ccp(xingxingImg->getContentSize().width / 2,xingxingImg->getContentSize().height / 2));
this->setContentSize(xingxingImg->getContentSize());
}
}
示例2: clickXilianJingHua
void ZhuangbeiXilianUI::clickXilianJingHua(CCObject *obj)
{
if (m_dInfoDialog)
{
m_dInfoDialog->removeFromParent();
m_dInfoDialog = NULL;
}
string tishiStr = LFStrings::getValue("XilianJingHuaShuoMing");
string cailiaoFileStr = "daoju_youlanzhiye.png";
//弹框背景
BaseSprite* dialog = BaseSprite::create("gongjiang_duanzao_cailiaobuzu_tanchukuang.png");
dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2 + 50));
//提示
{
BaseSprite *cailiaoBg = BaseSprite::create("daoju_kuang_bg.png");
dialog->addChild(cailiaoBg);
cailiaoBg->setPosition(ccp(cailiaoBg->getContentSize().width/2 + 10, dialog->getContentSize().height/2));
BaseSprite *cailiaoImg = BaseSprite::create(cailiaoFileStr);
cailiaoBg->addChild(cailiaoImg);
cailiaoImg->setPosition(ccp(cailiaoBg->getContentSize().width/2, cailiaoBg->getContentSize().height/2));
CCLabelTTF* lable = CCLabelTTF::create(tishiStr.c_str(), fontStr_kaiti,20,CCSize(240, 0), kCCTextAlignmentLeft);
dialog->addChild(lable);
lable->setAnchorPoint(ccp(0,0.5));
lable->setPosition(ccp(cailiaoBg->getPositionX()+cailiaoBg->getContentSize().width/2 , dialog->getContentSize().height/2));
}
//按键
CCMenu* menu = CCMenu::create();
{
CCMenuItemImage* item = CCMenuItemImage::create(
"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
this, menu_selector(ZhuangbeiXilianUI::clickCiaoliaoShuoMing));
menu->addChild(item);
item->setPosition(ccp(dialog->getContentSize().width/2, dialog->getContentSize().height/2));
item->setOpacity(0);
item->setScaleX(mWinSize.width / dialog->getContentSize().width);
item->setScaleY(mWinSize.height / dialog->getContentSize().height);
// item->setScaleX(mWinSize.width / item->getContentSize().width);
// item->setScaleY(mWinSize.height / item->getContentSize().height);
}
//弹框
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setBaseContainer(dialog,menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128);
lfAlert->release();
m_dInfoDialog = lfAlert;
}
}
示例3: tableCellTouched
void GongJiang_EquipSelect::tableCellTouched(CCTableView* table, CCTableViewCell* cell)
{
BaseSprite* bg = (BaseSprite*)cell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM);
// 先不管是否点击了图片
// 先移除上一个点击的
if (selectedIndex >= 0)
{
CCTableViewCell* lastCell = table->cellAtIndex(selectedIndex);
if (lastCell)
{
lastCell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM)->removeChildByTag(TAG_BG_MASK_PIC);
}
}
// 再次选自己,代表取消
if (selectedIndex == cell->getIdx())
{
selectedIndex = -1;
}
else
{
selectedIndex = cell->getIdx();
BaseSprite* addEff = BaseSprite::create("mianban_zhuangbei_xiangxi_select.png");
bg->addChild(addEff,10,TAG_BG_MASK_PIC);
addEff->setPosition(ccp(bg->getContentSize().width/2,bg->getContentSize().height/2));
}
if(selectedIndex < 0)
{
mMenuItemMakeSure->setEnabled(false);
}
else
{
mMenuItemMakeSure->setEnabled(true);
}
bool isFirstIn = false;
// 先不管是否点击了图片
if(GameGuideManager::getManager()->isGuideNow(GameGuideManager::GID_GongJiang_QiangHua))
{
//GameGuideManager::getManager()->setOneGuideStart(GameGuideManager::GID_GongJiang_QhHt);
GameGuideManager::getManager()->setOneGuideEnd(GameGuideManager::GID_GongJiang_QiangHua);
if (mMenuItemMakeSure)
{
CCPoint pos = mMenuItemMakeSure->getParent()->convertToWorldSpace(mMenuItemMakeSure->getPosition());
GuideLayerBase *guideLayer1 = new GuideLayer_SimpleLayer;
guideLayer1->init(mMenuItemMakeSure->getContentSize(),pos
, LFStrings::getValue("DingjiQueding"), NULL, false);
//((GuideLayer_SimpleLayer*)guideLayer1)->setCallBack(this,SEL_CallFunc(&JiuGongGeLayer::GuiDeLayerCallBack));
CCDirector::sharedDirector()->getRunningScene()->addChild(guideLayer1, 128);
}
}
}
示例4: getItemContentByIndex
BaseSprite* GongJiang_EquipSelect::getItemContentByIndex(unsigned int index)
{
BaseSprite* ret = MainLayerZhuangBeiBaseBody::getItemContentByIndex(index);
if (selectedIndex == index)
{
BaseSprite* addEff = BaseSprite::create("mianban_zhuangbei_xiangxi_select.png");
ret->addChild(addEff,10,TAG_BG_MASK_PIC);
addEff->setPosition(ccp(ret->getContentSize().width/2,ret->getContentSize().height/2));
}
return ret;
}
示例5: tableCellAtIndex
CCTableViewCell* TanSuoLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCTableViewCell *cell = table->dequeueCell();
if (cell != NULL)
{
cell->removeAllChildren();
}
else
{
cell = new CCTableViewCell();
cell->autorelease();
}
if (table->getParent() != NULL)
{
CCSize cellSize = tableCellSizeForIndex(table, idx);
Profession profId = mHeros.at(idx)->getCurrentProperty().profession;
//head Profession 1-10
BaseSprite *headImg = BaseSprite::create(ImageManager::getManager()->getImageData_ProfessionHead(profId).getCurrentImageFile());
cell->addChild(headImg);
headImg->setPosition(ccp(cellSize.width/2, 92));
//menu
FXScrollMenu *menu = FXScrollMenu::create(
table->getParent()->convertToWorldSpace(table->getPosition()), table->getViewSize());
cell->addChild(menu, 1);
menu->setPosition(ccp(0,0));
CCMenuItemImage *item = CCMenuItemImage::create(
"renxing_renwu_touxiang.png",
"renxing_renwu_touxiang_select.png",
"renxing_renwu_touxiang_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_JieFenHeroSelect));
menu->addChild(item, 0, profId);
m_lMenuItemList.push_back(item);
item->setPosition(headImg->getPosition());
//name
CCLabelTTF *nameLabel = CCLabelTTF::create(BaseActorPropertyParser::getParser()->getExtraProerty(profId).nameInChinese.c_str()
, fontStr_kaiti, m_nFontSize);
cell->addChild(nameLabel);
nameLabel->setPosition(ccp(headImg->getPositionX()
, headImg->getPositionY()-headImg->getContentSize().height/2-nameLabel->getContentSize().height/2));
nameLabel->setColor(ccc3(195, 145, 96));
}
return cell;
}
示例6: CCSizeMake
// 06-15 11:43:50.179: D/cocos2d-x debug info(1716): Get data from file(tabulation_armor_helmet_1.png) failed!
MainLayerZhuangBeiBaseBody::MainLayerZhuangBeiBaseBody(ZhuangbeiXiangQingFrom from)
{
mFrom = from;
mTableView = CCTableView::create(this, CCSizeMake(624,678));
addChild(mTableView);
mTableView->setDirection(kCCScrollViewDirectionVertical);
mTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
mTableView->setPosition(ccp(8,74));
mTableView->setDelegate(this);
mFooterForPop = NULL;
mClickedIdx = 0;
BaseSprite *bar = BaseSprite::create("mianban_zhuangbeishuliang_bg.png");
addChild(bar, 10);
bar->setPosition(ccp(320, 43));
CCString temp;
temp.initWithFormat("%s: %d/%u", LFStrings::getValue("zhuangbei").c_str()
, MyselfManager::getManager()->getAllEquipmentsWithOutEquipedOrChuanQi().size(), MAX_COUNTS_IN_KNAPSACK);
m_zbTotalLabel = CCLabelTTF::create(temp.getCString(), fontStr_kaiti, 20);
m_zbTotalLabel->setAnchorPoint(ccp(1, 0.5));
m_zbTotalLabel->setPosition(ccp(bar->getContentSize().width-20, bar->getContentSize().height/2));
bar->addChild(m_zbTotalLabel);
//分解提示
m_zbFenJieTiShi = CCLabelTTF::create(LFStrings::getValue("ZBCountMax_GanKuaiQuFenJieBa").c_str(), fontStr_kaiti, 20);
bar->addChild(m_zbFenJieTiShi);
m_zbFenJieTiShi->setPosition(ccp(bar->getContentSize().width/2, bar->getContentSize().height/2));
m_zbFenJieTiShi->setColor(fonColor_JingGao);
m_zbFenJieTiShi->setVisible(false);
m_zbFenJieMenu = CCMenu::create();
bar->addChild(m_zbFenJieMenu);
m_zbFenJieMenu->setPosition(ccp(0,0));
m_zbFenJieMenu->setVisible(false);
CCMenuItemImage *fenjie = CCMenuItemImage::create(
"mianban_zhuangbei_qufenjie.png",
"mianban_zhuangbei_qufenjie_select.png",
this, menu_selector(MainLayerZhuangBeiBaseBody::menuitemClicked_GotoFenJie));
m_zbFenJieMenu->addChild(fenjie);
fenjie->setPosition(ccp(m_zbTotalLabel->getPositionX()-fenjie->getContentSize().width/2, m_zbTotalLabel->getPositionY()));
if (mFrom != From_ZhuangBeiList)
{
m_zbFenJieMenu->removeFromParent();
}
}
示例7: initBg
void ClassicScene::initBg()
{
CCSprite *bg = SPRITE(images/stage_classic/stage_bg_RETINA.png);
bg->setPosition(VisibleRect::center());
addChild(bg);
CCSprite *bgWood = SPRITE(images/stage_classic/stage_tree_RETINA.png);
CCSprite *floor = SPRITE(images/stage_classic/stage_tree_grass_RETINA.png);
floor->setPosition(ccp(VisibleRect::center().x,44));
bgWood->setPosition(ccp(VisibleRect::center().x,-400));
CCActionInterval *moveAct = CCMoveTo::create(0.6f,ccp(VisibleRect::center().x,400));
CCCallFunc *showBirdLayerHandler = CCCallFunc::create(this,callfunc_selector(ClassicScene::showBirdLayer));
bgWood->runAction(CCSequence::create(moveAct,showBirdLayerHandler,NULL));
addChild(bgWood);
birdLayer = BirdLayer::create();
birdLayer->setPosition(ccp(VisibleRect::center().x,-400));
addChild(birdLayer);
addChild(floor);
BaseSprite *pauseBtn = BaseSprite::createFromFile("images/stage_classic/stage_dimm2_RETINA.png","sounds/SFX/pausebuttonclick.mp3");
pauseBtn->setPosition(ccp(50,VisibleRect::top().y-50));
pauseBtn->setOpacity(0);
pauseBtn->setBeganTarget(this,menu_selector(ClassicScene::pauseGame));
addChild(pauseBtn);
}
示例8: 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));
//.........这里部分代码省略.........
示例9: init
bool ChatLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) );
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//board
CCSprite* board = CCSprite::create("juqing_duihuakuang.png");
addChild(board, 2, TAG_Board);
board->setAnchorPoint(ccp(0.5, 0));
board->setPosition(ccp(winSize.width/2, 0));
board->setOpacity(0);
//next img
BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png");
board->addChild(nextImg, 0, Tag_ImgNext);
nextImg->setPosition(ccp(597,37));
nextImg->setOpacity(0);
nextImg->runAction(CCSequence::create(
CCFadeIn::create(0.15f),
CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1),
NULL));
//npc
string npcFileName = getFileByName(m_chatContext.at(0).name).second;
////////////////////////////////////////////
if(npcFileName.empty())
{
CCLog("Error: %s [can't found npc imgine]", __FUNCTION__);
npcFileName = "juqing_duihua_NPC_shenmiren.png";
}
////////////////////////////////////////////
CCSprite* actorA = CCSprite::create(npcFileName.c_str());
addChild(actorA, 1, TAG_ActorA);
actorA->setAnchorPoint(ccp(0,0));
actorA->setPosition(ccp(0, board->getContentSize().height-14));
actorA->setOpacity(0);
//actor //yemanren cike fashi
string actorFileName = getFileByName("zhujue").second;
CCSprite* actorB = CCSprite::create(actorFileName.c_str());
addChild(actorB, 1, TAG_ActorB);
actorB->setAnchorPoint(ccp(1,0));
actorB->setPosition(ccp(winSize.width, board->getContentSize().height-14));
// actorB->setScale(0.9);
actorB->setOpacity(0);
//label name
CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24);
addChild(namelabel, 5, Tag_Label_Name);
namelabel->setAnchorPoint(ccp(0, 0.5));
namelabel->setPosition(ccp(20, board->getContentSize().height-42));
namelabel->setColor(fonColor_PuTong);
namelabel->setOpacity(0);
//label content
CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(610, 0), kCCTextAlignmentLeft);
addChild(label, 5, TAG_label);
label->setAnchorPoint(ccp(0,1));
label->setColor(fonColor_FaGuang);
label->setPosition(ccp(20, board->getContentSize().height-76));
label->setOpacity(0);
////////////start chat
if(m_chatContext.at(0).name == "zhujue")
actorB->runAction(CCFadeIn::create(0.1f));
else
actorA->runAction(CCFadeIn::create(0.1f));
board->runAction(CCFadeIn::create(0.1f));
label->runAction(CCFadeIn::create(0.1f));
namelabel->runAction(CCFadeIn::create(0.1f));
nextImg->runAction(CCFadeIn::create(0.15f));
scheduleOnce(schedule_selector(ChatLayer::showChatContext), 0.05f);
{
mTimeEnd = false;
mLabelFadeInEnd = false;
++m_index;
}
bRet = true;
}while(0);
return bRet;
}
示例10: CCSize
GetAwardLayer::GetAwardLayer(CCString info, vector<ItemInfo> items, vector<Flat_DuanzaoGroupZBInfo> equips)
{
CCLayerColor::initWithColor(ccc4(0,0,0,255));
CCSize visSize = CCDirector::sharedDirector()->getWinSize();
mBoard = BaseSprite::create("shangpin_goumai_tishikuang.png");
addChild(mBoard);
mBoard->setPosition(ccp(visSize.width/2, visSize.height/2));
//label 提示
{
CCLabelTTF* label = CCLabelTTF::create(info.getCString(),
fontStr_kaiti, 20, CCSize(425, 0), kCCTextAlignmentLeft);
label->setColor(ccWHITE);
mBoard->addChild(label, 1);
if (items.size() == 0 && equips.size() == 0)
{
label->setAnchorPoint(ccp(0.5, 0.5));
label->setPosition(ccp(mBoard->getContentSize().width/2, 222));
}
else
{
label->setAnchorPoint(ccp(0.5, 1));
label->setPosition(ccp(mBoard->getContentSize().width/2, 326));
}
}
//材料
int label_size = 20;
ccColor3B label_color = ccWHITE;
int allNum = items.size() + equips.size();
int posIdx = 0;
for (int i=0; i < items.size(); ++i, ++posIdx)
{
BaseSprite* cailiaoImg = BaseSprite::create("daoju_kuang_bg.png");
mBoard->addChild(cailiaoImg);
int pos_x = mBoard->getContentSize().width/2;
int delta = posIdx - allNum/2;
if(allNum % 2 == 0)
{
float del = delta + 0.5;
pos_x += del * (cailiaoImg->getContentSize().width + 10);
}
else
{
pos_x += delta * (cailiaoImg->getContentSize().width + 10);
}
cailiaoImg->setPosition(ccp(pos_x, mBoard->getContentSize().height/2+24));
//item img
BaseSprite * itemImg = BaseSprite::create(
ImageManager::getManager()->getItemFilename(items.at(i).type)); // .count .type
cailiaoImg->addChild(itemImg);
itemImg->setPosition(ccp(cailiaoImg->getContentSize().width/2, cailiaoImg->getContentSize().height/2));
//数量
char buf[20];
sprintf(buf, "\nx%u", items.at(i).count);
string temp = CS::getItemName(items.at(i).type);
temp += buf;
CCLabelTTF *labelShuliang = CCLabelTTF::create(temp.c_str(), fontStr_kaiti, label_size
, CCSize(0,0), kCCTextAlignmentCenter);
cailiaoImg->addChild(labelShuliang);
labelShuliang->setPosition(ccp(cailiaoImg->getContentSize().width/2, -labelShuliang->getContentSize().height/2));
labelShuliang->setColor(label_color);
}
for (int i=0; i<equips.size(); ++i, ++posIdx)
{
BaseSprite* diwenImg = BaseSprite::create(
ImageManager::getManager()->getImageData_DiWen_WithBianKuang(equips.at(i).zhuangbei_colour)); // .count .type
mBoard->addChild(diwenImg);
int pos_x = mBoard->getContentSize().width/2;
int delta = posIdx - allNum/2;
if(allNum % 2 == 0)
{
float del = delta + 0.5;
pos_x += del * (diwenImg->getContentSize().width + 10);
}
else
{
pos_x += delta * (diwenImg->getContentSize().width + 10);
}
diwenImg->setPosition(ccp(pos_x, mBoard->getContentSize().height/2+24));
//equip pic
string equipfile = equips.at(i).zhuangbei_pic;
equipfile = "minute_" + equipfile + ".png";
BaseSprite *s = BaseSprite::create(equipfile);
diwenImg->addChild(s);
s->setScale(0.23f);
s->setPosition(ccp(diwenImg->getContentSize().width/2,diwenImg->getContentSize().height/2));
//数量
char buf[20];
sprintf(buf, "\nx%d", 1);
string temp = equips.at(i).zhuangbei_name;
temp += buf;
CCLabelTTF *labelShuliang = CCLabelTTF::create(temp.c_str(), fontStr_kaiti, label_size
//.........这里部分代码省略.........
示例11: menuItemClicked_TanSuo
void TanSuoLayer::menuItemClicked_TanSuo(CCObject *pSender)
{
int tag = ((CCMenuItem*)pSender)->getTag();
if (tag == Tag_MenuItem_YiJianTanSuo)
{
if (m_bIsJieFeng)
{
string infoStr = LFStrings::getValue("XuYaoJieFeng");
UnblockWarnDialog* pDlg = UnblockWarnDialog::create(infoStr);
CCDirector::sharedDirector()->getRunningScene()->addChild(pDlg, 300);
return;
}
if (MyselfManager::getManager()->getMyZhuJueData()->getVipLevel() < 3)
{
FXToast *layer = FXToast::create(LFStrings::getValue("XunBao_VipNeed"));
CCDirector::sharedDirector()->getRunningScene()->addChild(layer);
return;
}
m_bDiscoverAll = true;
addObserver(callfuncO_selector(TanSuoLayer::rsp_tansuo), MSG_discoverRsp);
mCmdHlp->cmdDiscover(m_bDiscoverAll);
}
else if (tag == Tag_MenuItem_TanSuo)
{
m_bDiscoverAll = false;
addObserver(callfuncO_selector(TanSuoLayer::rsp_tansuo), MSG_discoverRsp);
mCmdHlp->cmdDiscover(m_bDiscoverAll);
}
else if (tag == Tag_MenuItem_JieFen)
{
if (mDestroyCount >= m_nMaxCountDestroy)
{
m_bIsJieFeng = true;
m_nSelectProId = -1;
if (! EquipmentManager::getManager()->isSpareEnoughToSaveEquip(1))
{
EquipBagNotEnoughDialog *layer = new EquipBagNotEnoughDialog;
layer->showGoToFenJieDialog();
}
CCSize visSize = CCDirector::sharedDirector()->getWinSize();
BaseSprite* dialog = BaseSprite::create("juqing_duihuakuang.png");
dialog->setPosition(ccp(visSize.width/2, visSize.height/2));
//label 提示
{
/*CCLabelTTF* label = CCLabelTTF::create(LFStrings::getValue("XunBao_XuanZeHeroTiShi").c_str(),
fontStr_kaiti, m_nFontSize, CCSize(425, 0), kCCTextAlignmentLeft);
label->setAnchorPoint(ccp(0.5, 1));
label->setPosition(ccp(dialog->getContentSize().width/2, 250));
dialog->addChild(label, 1);*/
CCLabelTTF *title = CCLabelTTF::create(LFStrings::getValue("JieChuFengYin").c_str(),fontStr_kaiti,m_nFontSize);
title->setAnchorPoint(ccp(0.5,1));
title->setPosition(ccp(dialog->getContentSize().width/2, 250));
dialog->addChild(title, 1);
CCLabelTTF *chuanqi = CCLabelTTF::create(LFStrings::getValue("ChuanQiZhuangBei").c_str(),fontStr_kaiti,m_nFontSize);
chuanqi->setAnchorPoint(ccp(0.5,1));
chuanqi->setPosition(ccp(title->getPositionX() - title->getContentSize().width / 2 + m_nFontSize * 7 + chuanqi->getContentSize().width / 2, 250));
dialog->addChild(chuanqi, 1);
chuanqi->setColor(ccc3(235,106,12));
}
{
m_lMenuItemList.clear();
//mHeros = MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_All, LF_UnLock);
mHeros = MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_ShangZheng, LF_UnLock);
//tabel view
CCTableView *tabelView = CCTableView::create(this, CCSizeMake(560, 158));
tabelView->setDirection(kCCScrollViewDirectionHorizontal);
tabelView->setPosition(ccp(41, 44));
tabelView->setDelegate(this);
dialog->addChild(tabelView);
tabelView->reloadData();
}
//确认 取消按键
CCMenu* menu = CCMenu::create();
menu->setPosition(CCPointZero);
menu->setTag(0);
//
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setTag(TAG_AwardDisplayer_Layer);
lfAlert->setBaseContainer(dialog,menu);
lfAlert->setZoneCanotTouch();
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128, TAG_AwardDisplayer_Layer);
lfAlert->release();
}
return;
}
else
{
MessageDisplay* layer = MessageDisplay::create("ERROR!");
CCDirector::sharedDirector()->getRunningScene()->addChild(layer);
return;
}
}
//.........这里部分代码省略.........
示例12: init
bool ZhuShouChatLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) );
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//board
CCSprite* board = CCSprite::create("juqing_duihuakuang.png");
addChild(board, 2, TAG_Board);
board->setAnchorPoint(ccp(0.5, 0));
board->setPosition(ccp(winSize.width/2, 0));
board->setOpacity(0);
board->setScaleY(0.7f);
//next img
BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png");
board->addChild(nextImg, 0, Tag_ImgNext);
nextImg->setPosition(ccp(597,37));
nextImg->setOpacity(0);
nextImg->runAction(CCSequence::create(
CCFadeIn::create(0.15f),
CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1),
NULL));
//npc
string npcFileName = getFileByName(getPinyinName(m_nZhuaShouId)).second;
////////////////////////////////////////////
if(npcFileName.empty())
{
CCLog("Error: %s [can't found npc imgine]", __FUNCTION__);
npcFileName = "juqing_duihua_NPC_shenmiren.png";
}
////////////////////////////////////////////
int x_side = 20;
CCSprite* actorA = CCSprite::create(npcFileName.c_str());
addChild(actorA, 3, TAG_ActorA);
actorA->setAnchorPoint(ccp(0,0));
actorA->setPosition(ccp(x_side,x_side));
actorA->setOpacity(0);
int side = 10;
//label name
CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24);
addChild(namelabel, 5, Tag_Label_Name);
namelabel->setAnchorPoint(ccp(0, 0.5));
namelabel->setPosition(ccp(20, board->getContentSize().height-42));
namelabel->setColor(fonColor_PuTong);
namelabel->setOpacity(0);
//label content
//CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(board->getContentSize().width - actorA->getContentSize().width - side, 0), kCCTextAlignmentLeft);
m_nTextWidth = board->getContentSize().width - actorA->getContentSize().width - side;
NetLabelTTF* label = NetLabelTTF::create("", fontStr_kaiti, 24);
addChild(label, 5, TAG_label);
label->setHorizontalAlignment(kCCTextAlignmentLeft);
label->setAnchorPoint(ccp(0,1));
label->setColor(fonColor_FaGuang);
label->setPosition(ccp(actorA->getContentSize().width + side, board->getContentSize().height-145));
label->setOpacity(0);
actorA->runAction(CCFadeIn::create(0.0f));
board->runAction(CCFadeIn::create(0.0f));
label->runAction(CCFadeIn::create(0.0f));
namelabel->runAction(CCFadeIn::create(0.0f));
nextImg->runAction(CCFadeIn::create(0.0f));
scheduleOnce(schedule_selector(ZhuShouChatLayer::showChatContext), 0.05f);
{
mTimeEnd = false;
mLabelFadeInEnd = false;
++m_index;
}
bRet = true;
} while(0);
return bRet;
}
示例13: menuItemClicked_jiesuoHero
void MainLayerHerosBaseBody::menuItemClicked_jiesuoHero(CCObject *pSender)
{
int idx = ((CCMenuItemImage*)pSender)->getTag();
char buf[128];
if (mHerosVec.at(idx)->canUnlock())
{
mJieSuo_HeroId = mHerosVec.at(idx)->getId();
//弹框背景
BaseSprite* dialog = BaseSprite::create("shangpin_goumai_tishikuang.png");
dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2));
dialog->setTag(Tag_Window_JieSuo);
//label
CCString temp;
//解锁此助手需要花费\n%d荣誉值\n(当前荣誉:%d)
temp.initWithFormat(LFStrings::getValue("JieSuoZhuShouXuYao_RongYuZhi").c_str(),
CS::AssistantUnLockNeedHonor(MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_All, LF_Locked).size()),
MyselfManager::getManager()->getEdiableArenaTeamBasicInfo()->jifen);
CCLabelTTF *label = CCLabelTTF::create(temp.getCString(), fontStr_kaiti, 30, CCSize(400, 0), kCCTextAlignmentCenter);
dialog->addChild(label);
label->setAnchorPoint(ccp(0.5, 1));
label->setPosition(ccp(dialog->getContentSize().width/2, 278));
//按键
CCMenu* menu;
{
CCMenuItemImage* menuItemMakeSure = CCMenuItemImage::create(
"shangpin_goumai_queren.png",
"shangpin_goumai_queren_select.png",
this,SEL_MenuHandler(&MainLayerHerosBaseBody::menuItemClicked_LockHero_OkCancel));
CCMenuItemImage* menuItemCacel = CCMenuItemImage::create(
"shangpin_goumai_quxiao.png",
"shangpin_goumai_quxiao_select.png",
this,SEL_MenuHandler(&MainLayerHerosBaseBody::menuItemClicked_LockHero_OkCancel));
menu = CCMenu::create(menuItemMakeSure, menuItemCacel, NULL);
menu->setPosition(CCPointZero);
menuItemMakeSure->setTag(10);
menuItemCacel->setTag(20);
menuItemMakeSure->setPosition(ccp(dialog->getContentSize().width/3*2,70));
menuItemCacel->setPosition(ccp(dialog->getContentSize().width/3, 70));
}
//弹框
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setTag(Tag_Window_JieSuo);
lfAlert->setBaseContainer(dialog,menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert, 128, Tag_Window_JieSuo);
lfAlert->release();
}
}
else
{
sprintf(buf, LFStrings::getValue("XuYaoZhuJueDengJi_jiesuo").c_str(), 15);
MessageDisplay *layer = MessageDisplay::create(buf);
CCDirector::sharedDirector()->getRunningScene()->addChild(layer);
return;
}
}
示例14: clickShuoming
void ZhuangbeiXilianUI::clickShuoming(CCObject *obj)
{
//弹框
BaseSprite* dialog = BaseSprite::create("shangpin_goumai_tishikuang.png");
dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2));
//确认 取消按键
CCMenu* menu = CCMenu::create();
menu->setPosition(CCPointZero);
{
//返回
CCMenuItemImage *fanhui = CCMenuItemImage::create(
"shuxing_renwu_fanhui.png"
, "shuxing_renwu_fanhui_select.png"
, this, menu_selector(ZhuangbeiXilianUI::menuItemClicked_ShuoMingMenu));
menu->addChild(fanhui, 1, 20);
fanhui->setPosition(ccp(dialog->getContentSize().width/2,70));
}
//content
{
CCSize size = dialog->getContentSize();
//title
CCLabelTTF *titleLabel = CCLabelTTF::create(LFStrings::getValue("XilianTitle").c_str(), fontStr_kaiti, 20);
titleLabel->setHorizontalAlignment(kCCTextAlignmentCenter);
dialog->addChild(titleLabel);
titleLabel->setAnchorPoint(ccp(0.5,1));
titleLabel->setPosition(ccp(size.width/2, size.height-56));
CCLabelTTF *shuoMingLabel = CCLabelTTF::create(LFStrings::getValue("XilianInfo").c_str(), fontStr_kaiti, 20 );
shuoMingLabel->setHorizontalAlignment(kCCTextAlignmentRight);
dialog->addChild(shuoMingLabel);
shuoMingLabel->setColor(fonColor_PuTong);
shuoMingLabel->setAnchorPoint(ccp(0.5,1));
shuoMingLabel->setPosition(ccp(size.width/2, size.height-110));
CCPoint pos = shuoMingLabel->getPosition();
pos.x += shuoMingLabel->getContentSize().width / 2 - 45;
pos.y += 5;
int side_y = 20;
for (int i = 0 ; i < 4 ; i ++)
{
BaseSprite *xingxingImg = BaseSprite::create(CCString::createWithFormat("gongming_anniu_%d.png",i + 1)->getCString());
dialog->addChild(xingxingImg);
CCPoint point;
point.x = pos.x - xingxingImg->getContentSize().width / 2 * 0.38f;
point.y = pos.y - i * side_y - xingxingImg->getContentSize().height / 2 * 0.38f;
xingxingImg->setPosition(point);
xingxingImg->setScale(0.38f);
}
}
//
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setTag(Tag_Board_ShuoMing);
lfAlert->setBaseContainer(dialog,menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128, Tag_Board_ShuoMing);
lfAlert->release();
}
}
示例15: getFullPhotoOfActor
// 需要的架子图片:
// 战斗内的架子:qsx_[关键字]_jiazhi_[_双手].png; // 这是空架子 qsx_[关键字]_yuanshen_[_双手].png;
// 如果是有盔甲,那么直接用盔甲的图片作为架子
// qsx:全身相.
// 比如 qsx_barbarian_jiazhi_shuangshou.png/qsx_barbarian_yuanshen_shuangshou.png
// 比如 qsx_barbarian_jiazhi.png/qsx_barbarian_yuanshen.png
// 比如 qsx_barbarian_jiazhi.png/qsx_barbarian_yuanshen.png
// 没有装备的情况,就用默认的单双手.
// 怪物统一使用单手命名的图片,不管其到底是单双手
CCNode* ImageManager::getFullPhotoOfActor(Profession profession,vector<ZhuangbeiSummary> equips,bool yuanshen /* = false */,bool useDiZuo /* = true */,int stage /* = 1 */)
{
#define _JIAZHI "_jiazhi"
#define _YUANSHEN "_yuanshen"
// 1.确定单双手,盔甲的位置索引
int kuijia_pos = -1;
bool shuangshou = false;
int equipNum = equips.size();
for (int i=0;i<equipNum;i++)
{
if ( CS::isShuangShouWuQi(equips[i].zhuangbei_type) )
{
shuangshou = true;
}
if (equips[i].zhuangbei_type == ZhuangbeiType_KuijiaQin || equips[i].zhuangbei_type == ZhuangbeiType_KuijiaZhong)
{
CCAssert(kuijia_pos == -1,"");
kuijia_pos = i;
}
}
// 断言 怪物, 全用单手,不会有盔甲
if (profession > Profession_GW_Start && profession < Profession_GW_End || profession>=Profession_Big_Boss_1)
{// 知己用zhandou_guai_****.png图片
CCAssert(equipNum<=0,"怪物不可能有装备");
CCAssert(shuangshou == false,"怪物无装备");
CCAssert(kuijia_pos == -1,"怪物无盔甲");
CCNode* node = CCNode::create();
// zhandou_guai_jiangshi_dizuo.png
CCNode* dizuo = BaseSprite::create("qsx_dizuo.png");
// zhandou_guai_jiangshi.png
BaseSprite* jiazi_node = BaseSprite::create("zhandou_guai_"+getBaseImageName(profession)+".png");
node->addChild(dizuo,0,TAG_FULL_PHOTO_DIZUO);
node->addChild(jiazi_node,0,TAG_FULL_PHOTO_JIAZI);
dizuo->setPosition(ccp(0,-jiazi_node->getContentSize().height/2+dizuo->getContentSize().height/2));
return node;
}
// 其他的助手,那么该双手就双手,该单手,就单手
switch (profession)
{
case Profession_Yemanren:
break;
case Profession_Chike:
break;
case Profession_Fashi:
break;
case Profession_Qishi:
shuangshou = false;
break;
case Profession_ShenJianShou:
shuangshou = true;
break;
case Profession_MiShu:
shuangshou = true;
break;
case Profession_WuSeng:
shuangshou = false;
break;
case Profession_YouXia:
shuangshou = false;
break;
case Profession_LieShou:
shuangshou = true;
break;
case Profession_WuShi:
shuangshou = true;
break;
default:
CCLog("Waring : %s--> unkown profession = [%d]",__FUNCTION__,profession);
break;
}
// 元神的话就直接不用装备的图片
if (yuanshen)
{
kuijia_pos = -1;
equipNum = 0;
}
// 2.创建架子
BaseSprite* jiazi_node = NULL;
if (kuijia_pos == -1)
{// 没有盔甲,那么就直接用裸装架子
string handString = shuangshou?"_shuangshou":"";
string jiazi = "qsx_" + getBaseImageName(profession) + (yuanshen?_YUANSHEN:_JIAZHI) + handString + ".png";
jiazi_node = BaseSprite::create(jiazi);
}
else
//.........这里部分代码省略.........