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; }