本文整理汇总了C++中CCMenuItem::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItem::getContentSize方法的具体用法?C++ CCMenuItem::getContentSize怎么用?C++ CCMenuItem::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItem
的用法示例。
在下文中一共展示了CCMenuItem::getContentSize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool CChooseLetterWindow::init()
{
m_Back = Sprite::create("choose_letter.png");
m_Back->setPosition(600,384);
m_Back->setVisible(false);
addChild(m_Back);
std::vector<char> m_Letters;
m_Letters.resize(26);
m_Letters[0] = 'a'; m_Letters[1] = 'b'; m_Letters[2] = 'c'; m_Letters[3] = 'd'; m_Letters[4] = 'e'; m_Letters[5] = 'f'; m_Letters[6] = 'g';
m_Letters[7] = 'h'; m_Letters[8] = 'i'; m_Letters[9] = 'j'; m_Letters[10] = 'k'; m_Letters[11] = 'l'; m_Letters[12] = 'm'; m_Letters[13] = 'n';
m_Letters[14] = 'o'; m_Letters[15] = 'p'; m_Letters[16] = 'q'; m_Letters[17] = 'r'; m_Letters[18] = 's'; m_Letters[19] = 't'; m_Letters[20] = 'u';
m_Letters[21] = 'v'; m_Letters[22] = 'w'; m_Letters[23] = 'x'; m_Letters[24] = 'y'; m_Letters[25] = 'z';
float startPosX = -460.0f;
float startPosY = -150.0f;
float stepX = 45.0f;
float stepY = 45.0f;
int columnCount = 6;
int rowCount = 4;
int id = 0;
int currentColumn = 0;
int currentRow = 0;
m_pMenu = CCMenu::create();
for(int i=0;i<m_Letters.size();i++)
{
Point pos = Point(startPosX+(currentColumn*stepX),startPosY+(-currentRow*stepY));
CCMenuItem * button = CCMenuItemImage::create(
"base.png",
"fixed.png",
this,
menu_selector(CChooseLetterWindow::LetterBtnClick));
button->setTag(int(m_Letters[i]));
button->setScale(0.35f);
button->setPosition(pos);
LabelTTF * letterLabel = LabelTTF::create("0","helvetica",82);
letterLabel->setPosition(button->getContentSize().width/2,button->getContentSize().height/2);
letterLabel->setColor(Color3B(0,0,0));
std::string str = "A";
str[0] = m_Letters[i];
std::transform(str.begin(), str.end(),str.begin(), ::toupper);
letterLabel->setString(str);
button->addChild(letterLabel);
//letterLabel->setPosition(pos);
currentColumn++;
if(currentColumn == columnCount)
{
currentColumn = 0;
currentRow++;
}
m_pMenu->addChild(button);
m_pMenu->setEnabled(false);
}
m_Back->addChild(m_pMenu);
return true;
}
示例2:
CCMenuItem *EPSpriteButton::itemWithSpriteFrame(CCSpriteFrame *spriteFrame1,
CCSpriteFrame *spriteFrame2,
CCSpriteFrame *contentSpriteFrame)
{
CCSprite *sp1 = CCSprite::spriteWithSpriteFrame(spriteFrame1);
CCSprite *sp2 = CCSprite::spriteWithSpriteFrame(spriteFrame2);
CCSprite *content = CCSprite::spriteWithSpriteFrame(contentSpriteFrame);
CCMenuItem *item = CCMenuItemSprite::itemFromNormalSprite(sp1,sp2);
content->setPosition(ccp(item->getContentSize().width/2,item->getContentSize().height/2));
item->addChild(content);
return item;
}
示例3: itemForTouchPM
CCMenuItem* CPullMachMenu::itemForTouchPM(CCTouch * touch)
{
CCPoint touchLocation = touch->getLocation();
if (m_pChildren && m_pChildren->count() > 0)
{
CCObject* pObject = NULL;
CCARRAY_FOREACH(m_pChildren, pObject)
{
CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
if (pChild && pChild->isVisible() && pChild->isEnabled())
{
CCPoint local = pChild->convertToNodeSpace(touchLocation);
CCRect r;
r.size = pChild->getContentSize();
r.origin.x = r.size.width * 0.2f;
r.size.width *= 0.6f;
r.origin.y = r.size.height * 0.2f;
r.size.height *= 0.8f;
if (r.containsPoint(local))
{
return pChild;
}
}
}
示例4: setSelectedIndex
void CCMenuItemToggle::setSelectedIndex(unsigned int index)
{
if( index != m_uSelectedIndex )
{
m_uSelectedIndex = index;
this->removeChildByTag(kCurrentItem, false);
CCMenuItem *item = m_pSubItems->getObjectAtIndex(m_uSelectedIndex);
this->addChild(item, 0, kCurrentItem);
CGSize s = item->getContentSize();
this->setContentSize(s);
item->setPosition( ccp( s.width/2, s.height/2 ) );
}
}
示例5: createMenu
void HelloWorld::createMenu()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *editorLabel = CCLabelTTF::create("Editor", "Marker Felt", 24);
CCMenuItem *toEditorItem = CCMenuItemLabel::create(editorLabel, this, menu_selector(HelloWorld::switchToEditor));
CCLabelTTF *menuLabel = CCLabelTTF::create("Menu", "Marker Felt", 24);
CCMenuItem *toMenuItem = CCMenuItemLabel::create(menuLabel, this, menu_selector(HelloWorld::switchToMenu));
CCMenu *menu = CCMenu::create(toMenuItem,toEditorItem,NULL);
menu->setPosition(ccp(winSize.width/2, toEditorItem->getContentSize().height/2));
this->addChild(menu,100);
menu->alignItemsHorizontallyWithPadding(winSize.width * 0.1);
}
示例6: initTopMenu
bool CCLobbyView::initTopMenu()
{
CCDirector* director = CCDirector::sharedDirector();
const CCSize winSize = director->getWinSize();
const CCSize mySize = this->getContentSize();
const CCPoint center = ccpMult( ccpFromSize( mySize ), 0.5f );
CCLabelTTF* consoleLabel = CCLabelTTF::create( "disconnected", "Arial", FONT_SIZE(24), CCSizeMake( winSize.width, FONT_SIZE(24) ), kCCTextAlignmentCenter );
consoleLabel->setColor( ccc3(255, 255, 255) );
CCMenuItemLabel* consoleItem = CCMenuItemLabel::create( consoleLabel );
// bottom
const CCSize editSize = CCSizeMake( winSize.width, FONT_SIZE(48) );
CCMenuItem* editItem = CCMenuItem::create();
editItem->setContentSize( editSize );
CCMenu* topMenu = CCMenu::create( consoleItem, editItem, NULL );
if( topMenu )
{
this->setConsole( consoleLabel );
topMenu->alignItemsVertically();
topMenu->setPosition( CCPointMake( center.x, winSize.height - (editItem->getContentSize().height + consoleItem->getContentSize().height)/2 ) );
this->addChild( topMenu, 0, Child::CCMenu_topMenu );
const CCPoint editItemPosition = editItem->getParent()->convertToWorldSpace( editItem->getPosition() );
editItem->setContentSize( winSize );
editItem->ignoreAnchorPointForPosition( false );
editItem->setAnchorPoint( ccp( 0.5f, (winSize.height / (editItemPosition.y - winSize.height)) * 0.5f ) );
CCScale9Sprite* editSprite = CCScale9Sprite::create("extensions/yellow_edit.png");
CCEditBox* edit = CCEditBox::create( editSize, editSprite );
edit->setPlaceHolder("PlayerName");
edit->setReturnType(kKeyboardReturnTypeDone);
edit->setFontColor(ccGRAY);
edit->setMaxLength( 20 );
edit->setDelegate(this);
edit->setTouchEnabled( true );
edit->setPosition( editItemPosition );
CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
JString userName = network->getUserName();
edit->setText(userName.UTF8Representation().cstr());
this->addChild( edit );
this->setEditName(edit);
}
return topMenu;
}
示例7: createMenu
KDvoid LevelEditor::createMenu ( KDvoid )
{
const CCSize& tLyrSize = this->getContentSize ( );
CCLabelTTF* pSaveLabel = CCLabelTTF::create ( "Save", "font/Marker Felt.ttf", 24 );
CCMenuItem* pSaveItem = CCMenuItemLabel::create ( pSaveLabel, this, menu_selector ( LevelEditor::saveLevel ) );
CCLabelTTF* pResetLabel = CCLabelTTF::create ( "Select Level", "font/Marker Felt.ttf", 24 );
CCMenuItemLabel* pResetItem = CCMenuItemLabel::create ( pResetLabel, this, menu_selector ( LevelEditor::resetLevel ) );
CCLabelTTF* pPlayLabel = CCLabelTTF::create("Play Level", "font/Marker Felt.ttf", 24);
CCMenuItemLabel* pPlayLevelItem = CCMenuItemLabel::create ( pPlayLabel, this, menu_selector ( LevelEditor::playLevel ) );
CCMenu* pMenu = CCMenu::create ( pSaveItem, pResetItem, pPlayLevelItem, KD_NULL );
pMenu->setPosition ( tLyrSize.cx / 2, pSaveItem->getContentSize ( ).cy / 2 );
this->addChild ( pMenu, 100 );
pMenu->alignItemsHorizontallyWithPadding ( 20 );
}
示例8: setSelectedIndex
void CCMenuItemToggle::setSelectedIndex(unsigned int index)
{
if( index != m_uSelectedIndex && m_pSubItems->count() > 0 )
{
m_uSelectedIndex = index;
CCMenuItem *currentItem = (CCMenuItem*)getChildByTag(kCurrentItem);
if( currentItem )
{
currentItem->removeFromParentAndCleanup(false);
}
CCMenuItem* item = (CCMenuItem*)m_pSubItems->objectAtIndex(m_uSelectedIndex);
this->addChild(item, 0, kCurrentItem);
CCSize s = item->getContentSize();
this->setContentSize(s);
item->setPosition( ccp( s.width/2, s.height/2 ) );
}
}
示例9: createMenu
void CMenuLayer::createMenu()
{
CCMenuItemFont::setFontSize( 32 );
CCMenuItemFont::setFontName("Courier New");
setTouchEnabled(true);
// Font Item
CCMenuItem* quit = CCMenuItemImage::create( "images/CloseNormal.png", "images/CloseSelected.png", this, menu_selector(CMenuLayer::onQuit) );
CCMenu* menu = CCMenu::create( quit, NULL);
menu->alignItemsVertically();
addChild( menu );
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSize itemSize = quit->getContentSize();
menu->setPositionX( winSize.width - itemSize.width / 2 );
menu->setPositionY( winSize.height - itemSize.height / 2 );
}
示例10: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
this->isTouchEnabled();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
//CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
// "CloseNormal.png",
// "CloseSelected.png",
// this,
// menu_selector(HelloWorld::menuCloseCallback));
//pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
//origin.y + pCloseItem->getContentSize().height/2));
CCMenuItem *pStartGameItem = CCMenuItemFont::create(
"Start Game",
this,
menu_selector(HelloWorld::startGame) );
pStartGameItem->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2));
CCMenuItem *pGameOptions = CCMenuItemFont::create(
"Options",
this,
menu_selector(HelloWorld::startOptionsMenu) );
pGameOptions->setPosition(ccp(origin.x + visibleSize.width - pGameOptions->getContentSize().width/2 ,
origin.y + pGameOptions->getContentSize().height/2));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pStartGameItem, NULL);
pMenu->setPosition(CCPointZero);
pMenu->addChild(pGameOptions);
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
CCLabelTTF* pLabel = CCLabelTTF::create("Ugly Brick Breaker EXTREME V0.1", "Arial", TITLE_FONT_SIZE);
// position the label on the center of the screen
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
// add the label as a child to this layer
this->addChild(pLabel, 1);
CCLabelTTF* authorLabel = CCLabelTTF::create("By: Steven Bauer", "Arial", TITLE_FONT_SIZE);
authorLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - 30 - authorLabel->getContentSize().height));
this->addChild(authorLabel, 2);
return true;
}
示例11: CCDirectorGetWindowsSize
bool
MCSkillLayer::init()
{
if (MCBaseInfoLayer::init()) {
CCSize winSize = CCDirectorGetWindowsSize();
float contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
CCMenu *menu;
CCLabelTTF *label;
CCMenuItem *menuItem;
float fontSize = 24.0f / contentScaleFactor;
float offsetXLeft = 200 / contentScaleFactor;
content_.push_back(JsonBox::Value("name"));
content_.push_back(JsonBox::Value("releaseTime"));
content_.push_back(JsonBox::Value("activeTime"));
content_.push_back(JsonBox::Value("coldTime"));
content_.push_back(JsonBox::Value("consume"));
content_.push_back(JsonBox::Value("requiredProficiency"));
content_.push_back(JsonBox::Value("revise"));
content_.push_back(JsonBox::Value("count"));
content_.push_back(JsonBox::Value("effect"));
selectedSkill_ = NULL;
/* 技能种类 */
menu = CCMenu::create();
label = CCLabelTTF::create("剑", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCSwordSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("锤", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCHammerSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("斧", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCAxeSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("枪", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCSpearSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("弓", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCBowSkill);
menu->addChild(menuItem);
menu->alignItemsVerticallyWithPadding(4);
addChild(menu);
menu->setAnchorPoint(ccp(0, 0.5));
menu->setPosition(ccp(offsetXLeft, winSize.height / 2));
/* 技能表格 */
tableViewSize_ = CCSizeMake(180 / contentScaleFactor,
320 / contentScaleFactor);
tableView_ = CCTableView::create(this, tableViewSize_);
addChild(tableView_);
tableView_->setDirection(kCCScrollViewDirectionVertical);
tableView_->setDelegate(this);
tableView_->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView_->setAnchorPoint(ccp(0, 0.5));
tableView_->setPosition(ccp(menu->getPositionX() + menuItem->getContentSize().width,
(winSize.height - tableViewSize_.height) / 2));
contentTableView_ = CCTableView::create(this, tableViewSize_);
addChild(contentTableView_);
contentTableView_->setDirection(kCCScrollViewDirectionVertical);
contentTableView_->setDelegate(this);
contentTableView_->setVerticalFillOrder(kCCTableViewFillTopDown);
contentTableView_->setAnchorPoint(ccp(0, 0.5));
contentTableView_->setPosition(ccp(tableView_->getPositionX() + tableViewSize_.width,
(winSize.height - tableViewSize_.height) / 2));
contentTableView_->setVisible(false);
icon_ = CCSprite::create();
addChild(icon_);
icon_->setAnchorPoint(ccp(1, 1));
icon_->setPosition(ccp(winSize.width - 64.0f / contentScaleFactor,
//.........这里部分代码省略.........
示例12: init
bool CSLayerPopupMsg::init(POPUPMSG_ENUM popEnum, string strTitle, string strMessage)
{
m_strMessage = strMessage;
m_strTitle = strTitle;
m_popEnum = popEnum;
CCSize size = CCDirector::sharedDirector()->getWinSize();
//添加背景
CCSprite *pSprite = CCSprite::spriteWithSpriteFrameName(m_strBackground.c_str());
pSprite->setPosition(ccp(size.width/2, size.height/2));
addChild(pSprite);
//标题栏
CCLabelTTF *pLabel = CCLabelTTF::labelWithString(m_strTitle.c_str(), "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(size.width*2/5, size.height*7/10));
pLabel->setColor(ccc3(200,200,255));
pSprite->addChild(pLabel);
//信息
pLabel = CCLabelTTF::labelWithString(m_strMessage.c_str(), "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(size.width/2, size.height/2));
pLabel->setColor(ccc3(155,155,255));
pSprite->addChild(pLabel);
//添加按钮
CCMenu *pMenu = CCMenu::menuWithItems(NULL);
pMenu->setPosition(CCPointZero);
CCMenuItem *pItem;
if (m_popEnum == POPUP_YESNOCANCEL)
{
pItem = CCMenuItemImage::itemFromNormalImage("Images/UI/common/0023.png", "Images/UI/common/0023.png", this, menu_selector(CSLayerPopupMsg::callbackClick));
pItem->setTag(RESPONSE_YES);
pItem->setPosition(ccp(size.width*3/10, size.height*2/5));
pMenu->addChild(pItem, 0);
pLabel = CCLabelTTF::labelWithString("确认", "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(pItem->getContentSize().width/2, pItem->getContentSize().height/2));
pItem->addChild(pLabel);
pItem = CCMenuItemImage::itemFromNormalImage("Images/UI/common/0022.png", "Images/UI/common/0022.png", this, menu_selector(CSLayerPopupMsg::callbackClick));
pItem->setTag(RESPONSE_NO);
pItem->setPosition(ccp(size.width*5/10, size.height*2/5));
pMenu->addChild(pItem, 0);
pLabel = CCLabelTTF::labelWithString("取消", "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(pItem->getContentSize().width/2, pItem->getContentSize().height/2));
pItem->addChild(pLabel);
pItem = CCMenuItemImage::itemFromNormalImage("Images/UI/common/0022.png", "Images/UI/common/0022.png", this, menu_selector(CSLayerPopupMsg::callbackClick));
pItem->setTag(RESPONSE_CANCEL);
pItem->setPosition(ccp(size.width*7/10, size.height*2/5));
pMenu->addChild(pItem, 0);
pLabel = CCLabelTTF::labelWithString("关闭", "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(pItem->getContentSize().width/2, pItem->getContentSize().height/2));
pItem->addChild(pLabel);
}
else if (m_popEnum == POPUP_YESNO)
{
pItem = CCMenuItemImage::itemFromNormalImage("Images/UI/common/0023.png", "Images/UI/common/0023.png", this, menu_selector(CSLayerPopupMsg::callbackClick));
pItem->setTag(RESPONSE_YES);
pItem->setPosition(ccp(size.width*3/10, size.height*2/5));
pMenu->addChild(pItem, 0);
pLabel = CCLabelTTF::labelWithString("确认", "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(pItem->getContentSize().width/2, pItem->getContentSize().height/2));
pItem->addChild(pLabel);
pItem = CCMenuItemImage::itemFromNormalImage("Images/UI/common/0022.png", "Images/UI/common/0022.png", this, menu_selector(CSLayerPopupMsg::callbackClick));
pItem->setTag(RESPONSE_NO);
pItem->setPosition(ccp(size.width*5/10, size.height*2/5));
pMenu->addChild(pItem, 0);
pLabel = CCLabelTTF::labelWithString("取消", "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(pItem->getContentSize().width/2, pItem->getContentSize().height/2));
pItem->addChild(pLabel);
}
else if (m_popEnum == POPUP_YES)
{
pItem = CCMenuItemImage::itemFromNormalImage("Images/UI/common/0023.png", "Images/UI/common/0023.png", this, menu_selector(CSLayerPopupMsg::callbackClick));
pItem->setTag(RESPONSE_YES);
pItem->setPosition(ccp(size.width*3/10, size.height*2/5));
pMenu->addChild(pItem, 0);
pLabel = CCLabelTTF::labelWithString("确认", "DFPHaiBaoW12-GB", 28);
pLabel->setPosition(ccp(pItem->getContentSize().width/2, pItem->getContentSize().height/2));
pItem->addChild(pLabel);
}
addChild(pMenu);
return true;
}
示例13: init
bool EndMenu::init()
{
if (!CCLayer::init())
{
return false;
}
endMenuBg = CCSprite::create("UI/EndMenu/endMenuBg.png");
endMenuBg->setPosition(ccp(winSize.width/2 , winSize.height/2));
this->addChild(endMenuBg);
CCMenuItem *retryButton = CCMenuItemImage::create("UI/EndMenu/retryButton.png",
"UI/EndMenu/retryButton.png",
this, menu_selector(EndMenu::RestartGame));
retryButton->setPosition(ccp(endMenuBg->getContentSize().width/2 - retryButton->getContentSize().width ,
endMenuBg->getContentSize().height/2 - retryButton->getContentSize().height));
CCMenuItem *backToMainButton = CCMenuItemImage::create("UI/EndMenu/mainMenuButton.png",
"UI/EndMenu/mainMenuButton.png",
this, menu_selector(EndMenu::GoToMainMenu));
backToMainButton->setPosition(ccp(endMenuBg->getContentSize().width/2 + retryButton->getContentSize().width ,
retryButton->getPosition().y));
CCArray *buttons = CCArray::create(retryButton , backToMainButton , NULL);
CCMenu *theMenu = CCMenu::createWithArray(buttons);
theMenu->setPosition(CCPointZero);
endMenuBg->addChild(theMenu);
distanceLabel = CCLabelTTF::create("0", GAME_FONT.c_str(), 35);
distanceLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
distanceLabel->setPosition(ccp(endMenuBg->getContentSize().width/2 ,
endMenuBg->getContentSize().height * 0.71f));
endMenuBg->addChild(distanceLabel);
mushroomLabel = CCLabelTTF::create("0", GAME_FONT.c_str(), 35);
mushroomLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
mushroomLabel->setAnchorPoint(ccp(0 , 0.5f));
mushroomLabel->setPosition(ccp(endMenuBg->getContentSize().width * 0.60f ,
endMenuBg->getContentSize().height * 0.62f));
endMenuBg->addChild(mushroomLabel);
bonusRoundLabel = CCLabelTTF::create("0", GAME_FONT.c_str(), 35);
bonusRoundLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
bonusRoundLabel->setAnchorPoint(ccp(0 , 0.5f));
bonusRoundLabel->setPosition(ccp(mushroomLabel->getPosition().x + mushroomLabel->getContentSize().width*2 , mushroomLabel->getPosition().y));
endMenuBg->addChild(bonusRoundLabel);
mushroomIcon = CCSprite::create("Collectable/mushroom.png");
mushroomIcon->setPosition(ccp(endMenuBg->getContentSize().width * 0.3f , mushroomIcon->getContentSize().height));
endMenuBg->addChild(mushroomIcon , 5);
char fn[64];
sprintf(fn , "%d" , totalCoins);
totalMushroomLabel = CCLabelTTF::create(fn, GAME_FONT.c_str(), 30);
totalMushroomLabel->setAnchorPoint(ccp(0 , 0.5f));
totalMushroomLabel->setPosition(ccp(mushroomIcon->getPosition().x + mushroomIcon->getContentSize().width , mushroomIcon->getPosition().y));
endMenuBg->addChild(totalMushroomLabel , 5);
return true;
}
示例14: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
// CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
// "CloseNormal.png",
// "CloseSelected.png",
// this,
// menu_selector(HelloWorld::menuCloseCallback));
//
//pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
// origin.y + pCloseItem->getContentSize().height/2));
// // create menu, it's an autorelease object
// CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
// pMenu->setPosition(CCPointZero);
// this->addChild(pMenu, 1);
// /////////////////////////////
// // 3. add your codes below...
// // add a label shows "Hello World"
// // create and initialize a label
//
// CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
//
// // position the label on the center of the screen
// pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
// origin.y + visibleSize.height - pLabel->getContentSize().height));
// // add the label as a child to this layer
// this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
//CCSprite* pSprite = CCSprite::create("HelloWorld.png");
// // position the sprite on the center of the screen
// pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// // add the sprite as a child to this layer
// this->addChild(pSprite, 0);
/*CCMenuItemLabel* labTtf = CCMenuItemLabel::create(CCLabelTTF::create("lable Menu Test","Arial",20),this,menu_selector(HelloWorld::clickImage));
labTtf->setPosition(ccp(visibleSize.width/2,visibleSize.height/10));
CCMenu *pMenuLabl = CCMenu::create(labTtf,NULL);
pMenuLabl->setPosition(CCPointZero);
this->addChild(pMenuLabl,1);*/
CCMenuItem *pImage = CCMenuItemImage::create("CloseNormal.png","CloseSelected.png",this,menu_selector(HelloWorld::clickImage));
pImage->setPosition(visibleSize.width - pImage->getContentSize().width/2,visibleSize.height/2);
CCMenu *pMenu = CCMenu::create(pImage,NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu,1);
return true;
}