本文整理汇总了C++中CCLabelTTF::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::getPosition方法的具体用法?C++ CCLabelTTF::getPosition怎么用?C++ CCLabelTTF::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::getPosition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constructView
void SGScrollLabel::constructView()
{
_arrayLabel = CCArray::create();
_arrayLabel->retain();
for(int i=0;i<=_arrayString->count()/this->getFirstRowWordCount();i++)
{
std::string string;
for(int h=i*this->getFirstRowWordCount();h<(i+1)*getFirstRowWordCount();h++)
{
if(h >= _arrayString->count())
{
break;
}
CCString *str = (CCString*)_arrayString->objectAtIndex(h);
string.append(str->getCString());
}
CCLabelTTF *label = CCLabelTTF::create(string.c_str(), FONT_BOXINFO, 24);
_arrayLabel->addObject(label);
}
CCPoint bottomCenter = ccp(_viewSize.width/2,0);
for(int i=0;i<_arrayLabel->count();i++)
{
CCLabelTTF *label = (CCLabelTTF*)_arrayLabel->objectAtIndex(i);
label->setPosition(ccpAdd(bottomCenter, ccp(0, - label->getContentSize().height)));
label->setOpacity(0.0f);
label->setHorizontalAlignment(kCCTextAlignmentLeft);
this->addChild(label);
//动画
CCDelayTime *delayTime = CCDelayTime::create(i*2.0f);
CCMoveTo *move2 = CCMoveTo::create(0.5f,ccpAdd(label->getPosition(), ccp(0, _viewSize.height/10)));
CCFadeIn *fadeIn = CCFadeIn::create(0.5f);
CCFiniteTimeAction *spawn1 = CCSpawn::create(move2,fadeIn,NULL);
CCMoveTo *move = CCMoveTo::create(5.0f, ccpAdd(label->getPosition(), ccp(0, _viewSize.height)));
CCMoveTo *move3 = CCMoveTo::create(0.5f, ccpAdd(label->getPosition(),ccp(0, _viewSize.height*11/10)));
CCFadeOut *fadeOut = CCFadeOut::create(0.5f);
CCFiniteTimeAction *spawn2 = CCSpawn::create(move3,fadeOut,NULL);
CCFiniteTimeAction *sequence = CCSequence::create(delayTime,spawn1,move,spawn2,NULL);
label->runAction(sequence);
}
CCDelayTime *delay = CCDelayTime::create(_arrayLabel->count()*2+5);
CCCallFunc *call = CCCallFunc::create(this, callfunc_selector(SGScrollLabel::callFunction));
CCFiniteTimeAction *sequence2 = CCSequence::create(delay,call,NULL);
this->runAction(sequence2);
}
示例2: showFont
void FontTest::showFont(const char *pFont)
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSize blockSize = CCSizeMake(s.width/3, 200);
float fontSize = 26;
removeChildByTag(kTagLabel1, true);
removeChildByTag(kTagLabel2, true);
removeChildByTag(kTagLabel3, true);
removeChildByTag(kTagLabel4, true);
CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24);
CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize,
blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]);
CCLabelTTF *center = CCLabelTTF::create("alignment center", pFont, fontSize,
blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx]);
CCLabelTTF *right = CCLabelTTF::create("alignment right", pFont, fontSize,
blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx]);
CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height);
CCLayerColor *rightColor = CCLayerColor::create(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height);
leftColor->ignoreAnchorPointForPosition(false);
centerColor->ignoreAnchorPointForPosition(false);
rightColor->ignoreAnchorPointForPosition(false);
top->setAnchorPoint(ccp(0.5, 1));
left->setAnchorPoint(ccp(0,0.5));
leftColor->setAnchorPoint(ccp(0,0.5));
center->setAnchorPoint(ccp(0,0.5));
centerColor->setAnchorPoint(ccp(0,0.5));
right->setAnchorPoint(ccp(0,0.5));
rightColor->setAnchorPoint(ccp(0,0.5));
top->setPosition(ccp(s.width/2,s.height-20));
left->setPosition(ccp(0,s.height/2));
leftColor->setPosition(left->getPosition());
center->setPosition(ccp(blockSize.width, s.height/2));
centerColor->setPosition(center->getPosition());
right->setPosition(ccp(blockSize.width*2, s.height/2));
rightColor->setPosition(right->getPosition());
this->addChild(leftColor, -1);
this->addChild(left, 0, kTagLabel1);
this->addChild(rightColor, -1);
this->addChild(right, 0, kTagLabel2);
this->addChild(centerColor, -1);
this->addChild(center, 0, kTagLabel3);
this->addChild(top, 0, kTagLabel4);
}
示例3: init
bool SGFirstAdvanceBox::init(SGBoxDelegate *bdg)
{
ResourceManager::sharedInstance()->bindTexture("sgfirstlayer/sgfirstlayer.plist", RES_TYPE_LAYER_UI, sg_firstAdvanceBox, LIM_PNG_AS_PNG);
if (!SGBaseBox::init(bdg,box_firstAdvanceTag,CCSizeMake(600, 450),true,true))//,CCSizeMake(535, 125)
{
return false;
}
CCPoint center = SGLayout::getPoint(kMiddleCenter);
fontbg->setPreferredSize(CCSizeMake(600-55,450-150));
fontbg->setPosition(ccpAdd(center,ccp(0,0)));
CCSprite *title = CCSprite::createWithSpriteFrameName("mainlayer_font_xzjj.png");
this->addChild(title);
title->setPosition(biao->getPosition());
CCLabelTTF *label = CCLabelTTF::create(str_AllTaskLayer_str22, FONT_BOXINFO, 26);
CCLabelTTF *label1 = CCLabelTTF::create(str_AllTaskLayer_str23, FONT_BOXINFO, 26);
this->addChild(label);
this->addChild(label1);
label->setColor(ccc3(0x92,0x34,0x00));
label1->setColor(ccc3(0x92,0x34,0x00));
// label->setColor(ccWHITE);
// label1->setColor(ccWHITE);
label1->setAnchorPoint(ccp(0, 0.5f));
label->setPosition(ccpAdd(center, ccp(0, -170)));
label1->setPosition(ccpAdd(label->getPosition(), ccp(-label->getContentSize().width*.5f, -label->getContentSize().height*1.0)));
SGButton *wjk = SGButton::createFromLocal("upwar_cell_bg.png", str_AllTaskLayer_str24, this, menu_selector(SGFirstAdvanceBox::advanceOfficer),ccp(0,3),FONT_PANGWA,ccWHITE,50,false,true);
int modelTag = SGStaticDataManager::shareStatic()->getGuideTagById(guide_tag_21);
wjk->setTag(modelTag);
this->addBtn(wjk);
wjk->setScaleX(0.9);
SGButton *zbk = SGButton::createFromLocal("upwar_cell_bg.png", str_AllTaskLayer_str25, this, menu_selector(SGFirstAdvanceBox::advanceEquipment),ccp(0,3),FONT_PANGWA,ccWHITE,50,false,true);
this->addBtn(zbk);
zbk->setScaleX(0.9);
wjk->setPosition(ccpAdd(center, ccp(0,wjk->getContentSize().height/2+20)));
zbk->setPosition(ccpAdd(center, ccp(0,-wjk->getContentSize().height/2-20)));
SGButton *backBtn = SGButton::create("box_btnbg.png", "public_font_quxiao.png", this, menu_selector(SGFirstAdvanceBox::boxClose),CCPointZero,false,true);
this->addBtn(backBtn);
backBtn->setPosition(ccpAdd(center, ccp(0, -450/2+5 -40)));
return true;
}
示例4: init
bool TitleLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
// Get window size
CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
// Create text label for title of game - "@stroids" - don't sue me Atari!
CCLabelTTF *title = CCLabelTTF::labelWithString("@stroids", "Courier", 64.0);
// Position title at center of screen
title->setPosition(ccp(windowSize.width / 2, windowSize.height/2));
// Add to layer
this->addChild(title, 1);
// Set the default CCMenuItemFont font
CCMenuItemFont::setFontName("Courier");
// Create "play," "scores," and "controls" buttons - when tapped, they call methods we define: playButtonAction and scoresButtonAction
CCMenuItemFont *playButton = CCMenuItemFont::itemFromString("play", this, menu_selector(TitleLayer::playButtonAction));
CCMenuItemFont *scoresButton = CCMenuItemFont::itemFromString("scores", this, menu_selector(TitleLayer::scoresButtonAction));
CCMenuItemFont *controlsButton = CCMenuItemFont::itemFromString("controls", this, menu_selector(TitleLayer::controlsButtonAction));
// Create menu that contains our buttons
CCMenu *menu = CCMenu::menuWithItems(playButton, scoresButton, controlsButton, NULL);
// Align buttons horizontally
menu->alignItemsHorizontallyWithPadding(20);
// Set position of menu to be below the title text
menu->setPosition(ccp(windowSize.width / 2, title->getPosition().y - title->getContentSize().height / 1.5));
// Add menu to layer
this->addChild(menu, 2);
return true;
}
示例5: if
bool S131More::setUpSubClass2()
{
bool bRet = false;
do
{
refreshItemImage->setOpacity(1.0);
CCSprite * showbigPicture = CCSprite::create("S13PLeftimg.png");
showbigPicture->setPosition( ScriptParser::getPositionFromPlist(plistDic,"S13PLeftimg"));
this->addChild(showbigPicture,zNum);
CCSprite * lineSprite = CCSprite::create("s13PMiddleString.png");
lineSprite->setPosition( ccp(showbigPicture->getPosition().x+showbigPicture->getContentSize().width/2+20,showbigPicture->getPosition().y-50));
this->addChild(lineSprite,zNum);
CCPoint titleCnPosition = CCPointMake(lineSprite->getPosition().x + 10,lineSprite->getPosition().y+lineSprite->getContentSize().height/2-40);
float lastTitlePositionY = titleCnPosition.y;
float lastLabelHeight;
float lastLabelPositionY = titleCnPosition.y;
CCSprite * dotTitleLineSprite = CCSprite::create("s131RightWordBottom.png");
const char * titleCnStr;
if (AppDelegate::S1NewsSelected ==10001)
{
titleCnStr = ScriptParser::getStringFromPlist(plistDic,"rightFirstTitleCn1");
}
else
{
titleCnStr = ScriptParser::getStringFromPlist(plistDic,"rightFirstTitleCn2");
}
float titleCnFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"rightFirstTitleCn");
CCSize titleCnSize = CCSizeMake(dotTitleLineSprite->getContentSize().width, titleCnFontSize);
CCLabelTTF *titleCnLabel = CCLabelTTF::create(titleCnStr, s1FontName_macro, titleCnFontSize,titleCnSize, kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
titleCnLabel->setAnchorPoint(ccp(0.0,0.5));
titleCnLabel->setPosition(ccp(titleCnPosition.x,lastTitlePositionY));
titleCnLabel->setColor(ccBLACK);
this->addChild(titleCnLabel,zNum);
const char * titleEnStr;
if (AppDelegate::S1NewsSelected ==10001)
{
titleEnStr = ScriptParser::getStringFromPlist(plistDic,"rightFirstTitleEn1");
}
else
{
titleEnStr = ScriptParser::getStringFromPlist(plistDic,"rightFirstTitleEn2");
}
float titleEnFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"rightFirstTitleEn");
CCSize titleEnSize = CCSizeMake(dotTitleLineSprite->getContentSize().width, titleCnFontSize);
CCLabelTTF *titleEnLabel = CCLabelTTF::create(titleEnStr, s1FontName_macro, titleEnFontSize,titleEnSize, kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
titleEnLabel->setAnchorPoint(ccp(0.0,0.5));
titleEnLabel->setPosition(ccp(titleCnLabel->getPosition().x+100,titleCnLabel->getPosition().y));
titleEnLabel->setColor(ccGRAY);
this->addChild(titleEnLabel,zNum);
lastLabelHeight = titleCnLabel->getContentSize().height;
lastLabelPositionY = titleCnLabel->getPosition().y-40;
dotTitleLineSprite->setPosition(ccp(titleCnLabel->getPosition().x + dotTitleLineSprite->getContentSize().width/2,titleCnLabel->getPosition().y-titleCnLabel->getContentSize().height+5));
this->addChild(dotTitleLineSprite,zNum);
if (AppDelegate::S1NewsSelected ==10001)
{
//rightDetailTitle = AppDelegate::rightDetailTitleMap1;
rightBigTitle = AppDelegate::rightDetailTitleMap1;
rightTime = AppDelegate::rightTimeMap1;
rightDetailTitle = AppDelegate::rightDetailSubTitleMap1;
}
else if(AppDelegate::S1NewsSelected ==10002)
{
//rightDetailTitle = AppDelegate::rightDetailTitleMap2;
rightBigTitle = AppDelegate::rightDetailTitleMap2;
rightTime = AppDelegate::rightTimeMap2;
rightDetailTitle = AppDelegate::rightDetailSubTitleMap2;
}
//rightBigTitle = ScriptParser::getGroupStringFromPlist(plistDic,"rightBigTitle");
CCSize scrollPicSize = ScriptParser::getSizeFromPlist(plistDic,"scrollPic");
CCPoint scrollPicPosition = ScriptParser::getPositionFromPlist(plistDic,"scrollPic");
pTableView = CCTableView::create(this, scrollPicSize);
pTableView->setDirection(kCCScrollViewDirectionVertical);
pTableView->setAnchorPoint(ccp(0.0,1.0));
pTableView->setPosition(scrollPicPosition);
pTableView->setDelegate(this);
pTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
this->addChild(pTableView,zNum+1000);
pTableView->reloadData();
//.........这里部分代码省略.........
示例6: update
void WordTreeScene::update(float dt) {
if( isIdle==true ) {
return;
}
totalIdleTimes += dt;
if( isProcessing==true ) {
return;
}
else if( totalIdleTimes>=5.0f ) {
totalIdleTimes = 0.0f;
CCUserDefault::sharedUserDefault()->setStringForKey("FromCppToObjC", "requestWord");
}
static CCSize designResolutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
ChipmunkManager::getInstance()->update(dt);
WordModels::getInstance()->update(dt);
Word* word = WordModels::getInstance()->getNotRenderedWord();
if( word!=NULL ) {
CCLabelTTF* wordLabel = CCLabelTTF::create(word->getWord()->getCString(), "Arial", DEFAULT_FONT_SIZE);
float offsetX = CCRANDOM_MINUS1_1()*400;
float offsetY = CCRANDOM_MINUS1_1()*300+100;
wordLabel->setPosition(ccp(designResolutionSize.width/2+offsetX,designResolutionSize.height/2+offsetY));
word->setLabel(wordLabel);
word->setRendered(true);
CCSprite* sprite = CCSprite::create("images/heart.png");
sprite->setPosition(wordLabel->getPosition());
CCSize labelSize = wordLabel->getContentSize();
float spriteScale = MAX(labelSize.width, labelSize.height)/HEART_IMAGE_SIZE;
sprite->setScale(spriteScale+spriteScale*0.3f);
word->setSprite(sprite);
this->addChild(sprite);
this->addChild(wordLabel);
updatePhysics(word);
word = NULL;
return;
}
word = WordModels::getInstance()->getDirtyWord();
if( word!=NULL ) {
CCLabelTTF* wordLabel = word->getLabel();
CCSprite* sprite = word->getSprite();
if( wordLabel!=NULL && sprite!=NULL ) {
wordLabel->setFontSize(DEFAULT_FONT_SIZE+LABEL_INCREASE_SCALE_PER_WORD*word->getCount());
CCSize labelSize = wordLabel->getContentSize();
float spriteScale = MAX(labelSize.width, labelSize.height)/HEART_IMAGE_SIZE;
sprite->setScale(spriteScale+spriteScale*0.3f);
CCScaleTo* scaleUp = CCScaleTo::create(0.2f, spriteScale+spriteScale*0.5f);
CCEaseIn* in = CCEaseIn::create(scaleUp, 2.0f);
CCScaleTo* scaleDown = CCScaleTo::create(0.2f, spriteScale+spriteScale*0.3f);
CCEaseOut* out = CCEaseOut::create(scaleDown, 2.0f);
CCSequence* sequence = CCSequence::create(in, out, NULL);
sprite->runAction(sequence);
updatePhysics(word);
}
return;
}
}
示例7: ccp
bool S4HeZuo::setUpSubClass()
{
bool bRet = false;
do
{
float firstStrFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"firstTitle");
CCLabelTTF *firstTitleLabel = CCLabelTTF::create(ScriptParser::getStringFromPlist(plistDic,"firstTitle"), s1FontName_macro, firstStrFontSize);
firstTitleLabel->setColor(ccc3(193.0,159.0,113.0));
firstTitleLabel->setPosition(ScriptParser::getPositionFromPlist(plistDic,"firstTitle"));
this->addChild(firstTitleLabel,zNum+1);
CCSprite * S1PSubBottomSprite = CCSprite::create("S1PSubBottom.png");
S1PSubBottomSprite->setPosition( ccp(origin.x+visibleSize.width/2,firstTitleLabel->getPosition().y-firstTitleLabel->getContentSize().height/2-10));
this->addChild(S1PSubBottomSprite,zNum);
map<string, string> naviGroupStrMap = ScriptParser::getGroupStringFromPlist(plistDic,"naviTitle");
float naviFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"naviTitle");
CCPoint naviStrPosition = ScriptParser::getPositionFromPlist(plistDic,"naviTitle");
for (int i=0; i<(int)naviGroupStrMap.size(); i++)
{
const char * labelStr = naviGroupStrMap[PersonalApi::convertIntToString(i+1)].c_str();
CCLabelTTF *pLabel = CCLabelTTF::create(labelStr, s1FontName_macro, naviFontSize);
pLabel->setPosition(ccp(naviStrPosition.x+(pLabel->getContentSize().width+20)*i,naviStrPosition.y));
pLabel->setColor(ccc3(128.0,128.0,128.0));
this->addChild(pLabel,zNum+1);
if ( AppDelegate::S4SelectNavi == i+1)
{
pLabel->setColor(ccc3(255.0,255.0,255.0));
CCSprite * selectFrameSprite = CCSprite::create("PSubNavBackground.png");
selectFrameSprite->setScaleX(pLabel->getContentSize().width/selectFrameSprite->getContentSize().width);
selectFrameSprite ->setPosition(pLabel->getPosition());
this->addChild(selectFrameSprite,zNum);
}
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
CCMenuItemSprite *aItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S4HeZuo::menuCallback));
CC_BREAK_IF(! aItem);
aItem->setPosition(pLabel->getPosition());
aItem->setContentSize(pLabel->getContentSize());
aItem->setTag(btnTag+i+1);
_menu ->addChild(aItem,zNum);
}
CC_BREAK_IF(! setUpSubClass2());
bRet = true;
} while (0);
return bRet;
}
示例8: getItemContentByIndex
BaseSprite* MainLayerZhuangBeiBaseBody::getItemContentByIndex(unsigned int index)
{
BaseSprite* bg = BaseSprite::create("mianban_zhuangbei_xiangxi.png");
CCString tempStr;
CCPoint picPos = ccp(75.0f, bg->getContentSize().height/2);
{
ImageData diWenData = ImageManager::getManager()->getImageData_DiWen_List(
mEquipmentVec[index]->getEquipColor(),
false,
mEquipmentVec[index]->isPartOfSuit(),
mEquipmentVec[index]->haveZhuanke());
BaseSprite* diWen = BaseSprite::create(diWenData.getCurrentImageFile());
diWen->setScale(diWenData.scale);
diWen->setPosition(picPos);
bg->addChild(diWen,0,TAG_BaseBody_TABLE_ITEM_DiWen);
{
BaseSprite *sprite = ImageManager::getManager()->getSpriteOfZhuangbei(mEquipmentVec[index],true,true);
//sprite->setScale(data.scale);
sprite->setScale(0.43f);
sprite->setPosition(picPos);
bg->addChild(sprite,0,TAG_BaseBody_TABLE_ITEM_Image);
}
//封印
if (mEquipmentVec[index]->isInFengYin())
{
BaseSprite *fyImg = BaseSprite::create("shenbing_fengyin_suo.png");
bg->addChild(fyImg, 0, TAG_BaseBody_TABLE_FengYin_Img);
fyImg->setPosition(diWen->getPosition());
fyImg->setScale(diWen->getContentSize().width*diWen->getScale() / fyImg->getContentSize().width);
}
}
// 添加图片识别区
{
ImageData selecedData = ImageManager::getManager()->getImageData_DiWen_Selected(
mEquipmentVec[index]->getEquipColor(),
false,//mEquipmentVec[index]->isShenBing(),
mEquipmentVec[index]->isPartOfSuit());
BaseSprite* menuItemSel = BaseSprite::create(selecedData.getCurrentImageFile());
menuItemSel->setScale(selecedData.scale);
CCSprite* menuRect = CCSprite::createWithTexture(menuItemSel->getTexture());
menuRect->setScale(0.0f);
FXScrollMenu *menu = FXScrollMenu::create(
mTableView->getParent()->convertToWorldSpace(mTableView->getPosition()), mTableView->getViewSize());
bg->addChild(menu, 0, TAG_BaseBody_MENU);
menu->setPosition(ccp(0,0));
CCMenuItemSprite* t = CCMenuItemSprite::create(menuRect,menuItemSel,this,SEL_MenuHandler(&MainLayerZhuangBeiBaseBody::itemImageClicked));
menu->addChild(t, 0, index);
t->setPosition(picPos);
}
float left_x_start = 160 - 4;
//名称
{
CCLabelTTF* label;
char str[64];
if (mEquipmentVec[index]->getEquipData().qianghua_data.qianghua_count != 0)
{
sprintf(str, "%s", mEquipmentVec[index]->getName().c_str());
}
else
{
sprintf(str, "%s", mEquipmentVec[index]->getName().c_str());
}
label = LF::lable(bg,str,ccp(left_x_start,190),24,fontStr_kaiti);
label->setTag(TAG_BaseBody_LABLE_NAME);
ccColor3B color = ImageManager::getManager()->getShowColor(mEquipmentVec[index]->getEquipColor(),false,mEquipmentVec[index]->isPartOfSuit());
label->setColor(color);
}
//类型
{
std::string typeStr =
CS::getZhuangbeiTypeName(mEquipmentVec[index]->getType(), mEquipmentVec[index]->getEquipColor());
CCLabelTTF* label;
label = LF::lable(bg,typeStr,ccp(left_x_start,165),18,fontStr_kaiti);
label->setTag(TAG_BaseBody_LABLE_TYPE);
label->setColor(fonColor_CiYao);
}
//白字
{
CCLabelTTF* label_baizhi = NULL;
bool hasBaiZhi = false;
{
float baizi = 0;
switch(mEquipmentVec[index]->getType())
{
case ZhuangbeiType_DanshouJian:
case ZhuangbeiType_ShuangshouBishou:
case ZhuangbeiType_ShuangshouFu:
//.........这里部分代码省略.........
示例9: 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();
}
}
示例10: initWithTitle
bool VVAlertView::initWithTitle(const char* aTitle, const char* aMessage, VVAlertViewDelegate* aDelegate, const char* aCancelBtnTitle, const char* aOtherBtnTitle)
{
if ( !VVPopupLayer::init() )
return false;
delegate = aDelegate;
overlayLayer->removeFromParentAndCleanup(true);
CCLabelTTF *titleLabel = NULL;
if( aTitle != NULL )
{
titleLabel = CCLabelTTF ::labelWithString(aTitle ,fontName.c_str(), titleFontSize);
}
CCScale9Sprite *bg = CCScale9Sprite::scale9SpriteWithFile(alertBG_name.c_str(), alert9patch_rect);
CCLabelTTF *msgLabel = CCLabelTTF::labelWithString(aMessage, CCSizeMake(maxWidth-borderPadding*4, 0), CCTextAlignmentCenter, fontName.c_str(), messageFontSize);
CCMenuItemSprite* btnCancel = CCMenuItemDynamic::dynamicItemWithTTFLabel(aCancelBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this,
menu_selector(VVAlertView::onBtnCancel),
btn9patch_rect, 255);
CCMenu *menu;
if (aOtherBtnTitle == NULL)
{
menu = CCMenu::menuWithItems(btnCancel, NULL);
}
else
{
CCMenuItemSprite* btnOk = CCMenuItemDynamic::dynamicItemWithTTFLabel(aOtherBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this,
menu_selector(VVAlertView::onBtnOk),
btn9patch_rect, 255);
menu = CCMenu::menuWithItems(btnCancel, btnOk, NULL);
menu->alignItemsHorizontallyWithPadding(betweenBtnPadding);
}
menu->setTouchPriority(VVTouchPriorityMenuOnPopupLayer);
addChild(bg);
if (titleLabel)
addChild(titleLabel);
addChild(msgLabel);
addChild(menu);
if (titleLabel)
totalHeight += titleLabel->getContentSize().height;
totalHeight += msgLabel->getContentSize().height;
totalHeight += btnCancel->getContentSize().height;
totalHeight += centerPadding;
totalHeight += messagePadding*2;
totalHeight += borderPadding*2;
float halfHeight = totalHeight/2;
if (titleLabel)
{
titleLabel ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height/2)); // -15 : top padding
msgLabel ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height - messagePadding - msgLabel->getContentSize().height/2 ));
}
else
{
msgLabel ->setPosition(ccp(0, halfHeight - borderPadding - msgLabel->getContentSize().height/2 ));
}
menu ->setPosition(ccp(0, -halfHeight + borderPadding + btnCancel->getContentSize().height/2));
bg->setContentSize(CCSizeMake(maxWidth, totalHeight));
// will be used for placing text field in the middle
centerOfMargin = (msgLabel->getPosition().y + menu->getPosition().y)/2;
return true;
}
示例11: ccp
bool
MCRoleBaseInfo::init(MCRole *aRole)
{
if (CCLayer::init()) {
CCPoint anchorPoint = ccp(0, 1);
CCPoint labelAnchorPoint = ccp(0, 0.05);
CCSize labelSize;
CCPoint labelPosition;
CCLabelTTF *separatorLabel;
float y;
float contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
CCSize faceBoxSize = CCSizeMake(72 / contentScaleFactor,
72 / contentScaleFactor);
CCRect faceBoxSourceRect = CCRectMake(0, 0, 34, 34);
CCRect faceBoxInseRect = CCRectMake(4, 4, 30, 30);
faceBox_ = CCScale9Sprite::create(kMCRoleBaseInfoFaceBoxFilepath,
faceBoxSourceRect,
faceBoxInseRect);
addChild(faceBox_);
faceBox_->setContentSize(faceBoxSize);
faceBox_->setAnchorPoint(anchorPoint);
faceBox_->setPosition(ccp(0, 0));
face_ = CCSprite::create(aRole->getFace()->getCString());
addChild(face_);
face_->setAnchorPoint(anchorPoint);
face_->setScale(64 / contentScaleFactor / face_->getContentSize().height);
face_->setPosition(ccp(4 / contentScaleFactor, -4 / contentScaleFactor));
faceBoxSelected_ = CCScale9Sprite::create(kMCRoleBaseInfoFaceBoxSelectedFilepath,
faceBoxSourceRect,
faceBoxInseRect);
addChild(faceBoxSelected_);
faceBoxSelected_->setContentSize(faceBoxSize);
faceBoxSelected_->setAnchorPoint(anchorPoint);
faceBoxSelected_->setPosition(ccp(0, 0));
faceBoxSelected_->setVisible(false);
CCSprite *valueBox = CCSprite::create(kMCRoleBaseInfoValueBoxFilepath);
addChild(valueBox);
valueBox->setOpacity(196);
valueBox->setAnchorPoint(anchorPoint);
valueBox->setPosition(ccp(faceBox_->getPositionX() + faceBoxSize.width, 0));
/* PP */
CCString *ccstring = CCString::createWithFormat("%-03.0f", aRole->getPP());
ppLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(ppLabel_);
labelSize = ppLabel_->getContentSize();
ppLabel_->setColor(ccc3(240, 240, 240));
ppLabel_->setAnchorPoint(labelAnchorPoint);
y = labelSize.height / 2 - faceBoxSelected_->getContentSize().height;
ppLabel_->setPosition(ccp(96 / contentScaleFactor, y));
ccstring->retain();
separatorLabel = CCLabelTTF::create(" / ", "Marker Felt", kMCFontSize);
addChild(separatorLabel);
separatorLabel->setColor(ccc3(240, 240, 240));
separatorLabel->setAnchorPoint(labelAnchorPoint);
separatorLabel->setPosition(ccp(96 / contentScaleFactor + labelSize.width, y));
labelPosition = separatorLabel->getPosition();
ccstring = CCString::createWithFormat("%03.0f", aRole->getMaxPP());
maxPPLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(maxPPLabel_);
maxPPLabel_->setColor(ccc3(240, 240, 240));
maxPPLabel_->setAnchorPoint(labelAnchorPoint);
maxPPLabel_->setPosition(ccp(labelPosition.x + separatorLabel->getContentSize().width, y));
ccstring->retain();
/* HP */
ccstring = CCString::createWithFormat("%-03hu", aRole->getHP());
hpLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(hpLabel_);
labelSize = hpLabel_->getContentSize();
hpLabel_->setColor(ccc3(51, 153, 51));
hpLabel_->setAnchorPoint(labelAnchorPoint);
y += labelSize.height;
hpLabel_->setPosition(ccp(96 / contentScaleFactor, y));
ccstring->retain();
separatorLabel = CCLabelTTF::create(" / ", "Marker Felt", kMCFontSize);
addChild(separatorLabel);
separatorLabel->setColor(ccc3(51, 153, 51));
separatorLabel->setAnchorPoint(labelAnchorPoint);
separatorLabel->setPosition(ccp(96 / contentScaleFactor + labelSize.width, y));
labelPosition = separatorLabel->getPosition();
ccstring = CCString::createWithFormat("%03hu", aRole->getMaxHP());
maxHPLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(maxHPLabel_);
maxHPLabel_->setColor(ccc3(51, 153, 51));
maxHPLabel_->setAnchorPoint(labelAnchorPoint);
maxHPLabel_->setPosition(ccp(labelPosition.x + separatorLabel->getContentSize().width, y));
ccstring->retain();
role_ = aRole;
aRole->retain();
//.........这里部分代码省略.........