本文整理汇总了C++中CCMenuItemFont::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemFont::getContentSize方法的具体用法?C++ CCMenuItemFont::getContentSize怎么用?C++ CCMenuItemFont::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemFont
的用法示例。
在下文中一共展示了CCMenuItemFont::getContentSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool MainMenuScreen::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
float menuY = origin.y + visibleSize.height/2;
float menuX = origin.x + visibleSize.width/2;
CCMenuItemFont* menuTravel = CCMenuItemFont::create("Travel", this, menu_selector(MainMenuScreen::menuStartCallback));
menuTravel->setPosition(ccp( menuX, menuY));
menuY += menuTravel->getContentSize().height;
CCMenuItemFont* menuParty = CCMenuItemFont::create("Party Editor", this, menu_selector(MainMenuScreen::menuPartyCallback));
menuParty->setPosition(ccp( menuX, menuY ));
menuY += menuTravel->getContentSize().height;
CCMenuItemFont* menuSpellbook = CCMenuItemFont::create("Spell Editor", this, menu_selector(MainMenuScreen::menuBookCallback));
menuSpellbook->setPosition(ccp( menuX, menuY ));
CCMenu* pMenu = CCMenu::create(menuTravel, menuParty, menuSpellbook, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
setTouchEnabled(true);
//registerWithTouchDispatcher();
return true;
}
示例2: init
bool RequestList::init()
{
if ( !CCLayer::init())
{
return false;
}
mPhotoLoadIndex = 0;
EziSocialObject::sharedObject()->setFacebookDelegate(this);
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
SCREEN_WIDTH = winSize.width;
SCREEN_HEIGHT = winSize.height;
CCLayerColor *backgroundLayer = CCLayerColor::create(ccc4(20, 100, 100, 255), SCREEN_WIDTH, SCREEN_HEIGHT);
this->addChild(backgroundLayer);
MENU_FONT_SCALE = SCREEN_HEIGHT/320;
// Back Menu
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(RequestList::showHomePage));
itemBack->setAnchorPoint(ccp(1, 0.5));
itemBack->setPosition(ccp(SCREEN_WIDTH - 10, (itemBack->getContentSize().height/2 + 2) * MENU_FONT_SCALE));
CCMenuItemFont *purgeItems = CCMenuItemFont::create("Clear Completed Requests",
this,
menu_selector(RequestList::clearCompletedRequest));
purgeItems->setAnchorPoint(ccp(0, 0.5));
purgeItems->setPosition(ccp(10, (itemBack->getContentSize().height/2 + 2) * MENU_FONT_SCALE));
itemBack->setScale(MENU_FONT_SCALE);
purgeItems->setScale(MENU_FONT_SCALE);
CCMenu *menuBack = CCMenu::create(itemBack, purgeItems, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
float gap = itemBack->getContentSize().height * 2 * MENU_FONT_SCALE + (10 * MENU_FONT_SCALE);
_fbIncomingRequestList = NULL;
refreshList();
SCALE_FACTOR = SCREEN_HEIGHT / 768.0f;
SCALE_FACTOR = MAX(0.5, SCALE_FACTOR);
PHOTO_SCALE = SCREEN_HEIGHT/1536;
if (PHOTO_SCALE <= 0.5 && PHOTO_SCALE > 0.25)
{
FB_DEFAULT_PHOTO = "fb_user_icon_half.jpg";
}
else if (PHOTO_SCALE < 0.25)
{
FB_DEFAULT_PHOTO = "fb_user_icon_quater.jpg";
}
CCSprite *sprite = CCSprite::create(FB_DEFAULT_PHOTO);
CELL_HEIGHT = (sprite->getContentSize().height) + (40 * PHOTO_SCALE);
mTableView = CCTableView::create(this, CCSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - gap));
mTableView->setDirection(kCCScrollViewDirectionVertical);
mTableView->setPosition(ccp(0, gap/2));
mTableView->setDelegate(this);
this->addChild(mTableView);
mTableView->reloadData();
ALL_DOWNLOAD_COMPLETE = true;
mLoadingImage = CCSprite::create("ball.png");
mLoadingImage->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
mLoadingImage->retain();
this->addChild(mLoadingImage);
this->hideLoadingAction();
return true;
}
示例3: init
bool FriendList::init()
{
if ( !CCLayer::init())
{
return false;
}
mEnableHighScoreDisplay = false;
mEnableInstalledDisplay = false;
mReadyForNextDownload = false;
mPhotoLoadIndex = 0;
EziSocialObject::sharedObject()->setFacebookDelegate(this);
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
SCREEN_WIDTH = winSize.width;
SCREEN_HEIGHT = winSize.height;
CCLayerColor *backgroundLayer = CCLayerColor::create(ccc4(20, 100, 100, 255), SCREEN_WIDTH, SCREEN_HEIGHT);
this->addChild(backgroundLayer);
MENU_FONT_SCALE = SCREEN_HEIGHT/320;
// Back Menu
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(FriendList::showHomePage));
itemBack->setPosition(ccp(SCREEN_WIDTH/2, (itemBack->getContentSize().height/2 + 2) * MENU_FONT_SCALE));
CCMenuItemFont *itemHighScore = CCMenuItemFont::create("High Scores", this, menu_selector(FriendList::showHighScoreList));
itemHighScore->setAnchorPoint(ccp(1, 0.5));
itemHighScore->setPosition(ccp((SCREEN_WIDTH-10), itemBack->getPositionY()));
CCMenuItemFont *allFriends = CCMenuItemFont::create("All Friends", this, menu_selector(FriendList::showAllFriendsList));
allFriends->setAnchorPoint(ccp(0, 0.5));
allFriends->setPosition(ccp((10), itemBack->getPositionY()));
CCMenuItemFont *installedOnly = CCMenuItemFont::create("Installed Only", this, menu_selector(FriendList::showInstalledList));
installedOnly->setAnchorPoint(ccp(0, 1));
installedOnly->setPosition(ccp((10), SCREEN_HEIGHT - 2));
CCMenuItemFont *notPlaying = CCMenuItemFont::create("Friends Not Playing", this, menu_selector(FriendList::showNotInstalledList));
notPlaying->setAnchorPoint(ccp(1, 1));
notPlaying->setPosition(ccp((SCREEN_WIDTH-10), SCREEN_HEIGHT - 2));
itemBack->setScale(MENU_FONT_SCALE);
itemHighScore->setScale(MENU_FONT_SCALE);
allFriends->setScale(MENU_FONT_SCALE);
installedOnly->setScale(MENU_FONT_SCALE);
notPlaying->setScale(MENU_FONT_SCALE);
CCMenu *menuBack = CCMenu::create(itemBack, itemHighScore, allFriends, installedOnly, notPlaying, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
float gap = itemBack->getContentSize().height * 2 * MENU_FONT_SCALE + (10 * MENU_FONT_SCALE);
mFriendList = NULL;
PHOTO_SCALE = SCREEN_HEIGHT/1536;
if (PHOTO_SCALE <= 0.5 && PHOTO_SCALE > 0.25)
{
FB_DEFAULT_PHOTO = "fb_user_icon_half.jpg";
}
else if (PHOTO_SCALE < 0.25)
{
FB_DEFAULT_PHOTO = "fb_user_icon_quater.jpg";
}
CCSprite *sprite = CCSprite::create(FB_DEFAULT_PHOTO);
CELL_HEIGHT = (sprite->getContentSize().height) + (40 * PHOTO_SCALE);
mTableView = CCTableView::create(this, CCSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - gap));
mTableView->setDirection(kCCScrollViewDirectionVertical);
mTableView->setPosition(ccp(0, gap/2));
mTableView->setDelegate(this);
this->addChild(mTableView);
mTableView->reloadData();
ALL_DOWNLOAD_COMPLETE = true;
mLoadingImage = CCSprite::create("ball.png");
mLoadingImage->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
mLoadingImage->retain();
this->addChild(mLoadingImage);
this->hideLoadingAction();
return true;
}
示例4: init
// 主菜单Layer对象创建时初始化, 用来完成布局主菜单的功能。 包括背景图片、菜单、背景音乐加载等。
bool MainMenu::init()
{
int remainder; // 菜单顶部空白
int divider; // 菜单间空白
int halfWidth;
// 必须先执行基类的方法
if(!CCLayer::init())
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
halfWidth = winSize.width / 2;
// 添加背景图片,放在最底层
CCSprite* background = CCSprite::create("background.png");
background->setPosition(ccp(halfWidth, winSize.height / 2));
addChild(background, 0);
CCSprite* title = CCSprite::create("title.png");
title->setAnchorPoint(ccp(0.5, 1));
title->setScale(0.5);
title->setPosition(ccp(halfWidth, winSize.height - 20));
addChild(title, 10);
// 添加菜单
CCMenuItemFont* startGame = CCMenuItemFont::create("start", this, menu_selector(MainMenu::startGame));
CCSize contentSize = startGame->getContentSize();
divider = contentSize.height; // 菜单间间隔单项高度的1/3
remainder = (winSize.height - divider * MAIN_MENU_NUM) * 3 / 5;
startGame->setAnchorPoint(ccp(0.5, 1));
startGame->setPosition(ccp(halfWidth, winSize.height - remainder));
startGame->setEnabled(false);
CCMenuItemFont* pauseGame = CCMenuItemFont::create("pause", this, menu_selector(MainMenu::pauseGame));
pauseGame->setAnchorPoint(ccp(0.5, 1));
pauseGame->setPosition(ccp(halfWidth, winSize.height - remainder - divider));
pauseGame->setEnabled(false);
pauseGame->setVisible(true);
CCMenuItemFont* resumeGame = CCMenuItemFont::create("resume", this, menu_selector(MainMenu::resumeGame));
resumeGame->setAnchorPoint(ccp(0.5, 1));
resumeGame->setPosition(ccp(halfWidth, winSize.height - remainder - divider));
resumeGame->setEnabled(false);
resumeGame->setVisible(false);
CCMenuItemFont* setting = CCMenuItemFont::create("setting", this, menu_selector(MainMenu::setting));
setting->setAnchorPoint(ccp(0.5, 1));
setting->setPosition(ccp(halfWidth, winSize.height - remainder - 2 * divider));
setting->setEnabled(false);
CCMenuItemFont* quit = CCMenuItemFont::create("quit", this, menu_selector(MainMenu::quit));
quit->setAnchorPoint(ccp(0.5, 1));
quit->setPosition(ccp(halfWidth, winSize.height - remainder - 3 * divider));
quit->setEnabled(false);
CCMenu* mainMenu = CCMenu::create(startGame, pauseGame, resumeGame, setting, quit, NULL);
mainMenu->setPosition(CCPointZero);
addChild(mainMenu, 11, MAIN_MENU_TAG);
// 对背景音乐进行预加载及设置, 默认背景音乐开启
isSound = true;
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str());
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str(), true);
return true;
}