Exemple #1
0
void BaseScene::buildHeader(int highlightIndex, const char* title, const char* description)
{
    _currentMenuIndex = highlightIndex;
    
    CCMenuItemImage* homeButton = CCMenuItemImage::create();
    homeButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_nrl"));
    homeButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
    homeButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
    homeButton->setTarget(this, menu_selector(BaseScene::loadHomeScene));
    homeButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    CCMenuItemImage* fbActionButton = CCMenuItemImage::create();
    fbActionButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_nrl"));
    fbActionButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_prd"));
    fbActionButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_dis"));
    fbActionButton->setTarget(this, menu_selector(BaseScene::loadFBActionScene));
    fbActionButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    if (EziSocialObject::sharedObject()->isFacebookSessionActive() == false)
    {
        fbActionButton->setEnabled(false);
    }
    
    CCMenuItemImage* helpButton = CCMenuItemImage::create();
    helpButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_nrl"));
    helpButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
    helpButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
    helpButton->setTarget(this, menu_selector(BaseScene::loadHelpScene));
    
    helpButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    switch (highlightIndex)
    {
        case 0:
            homeButton->setEnabled(false);
            break;
            
        case 1:
            fbActionButton->setEnabled(false);
            break;
            
        case 2:
            helpButton->setEnabled(false);
            break;
            
        default:
            break;
    }
    
    
    CCMenu* homeMenu = CCMenu::create(homeButton, fbActionButton, helpButton, NULL);
    homeMenu->alignItemsHorizontally();
    
    this->addChild(homeMenu);
    PlaceNode(homeMenu, 0.88, 0.98);
    
    // Add a line.
    CCLayerColor* lineLayer = CCLayerColor::create(ccc4(204, 204, 204, 204),
                                                   CCDirector::sharedDirector()->getVisibleSize().width,
                                                   1.0 * AppDelegate::SCREEN_SCALE_FACTOR);
    
    this->addChild(lineLayer);
    PlaceNode(lineLayer, 0.0, 0.8);
    lineLayer->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height - (7 * AppDelegate::SCREEN_SCALE_FACTOR));
    
    // Add Title
    CCLabelTTF* titleLabel = CCLabelTTF::create(title, "Arial", 50.0 * AppDelegate::SCREEN_SCALE_FACTOR);
    this->addChild(titleLabel);
    titleLabel->setAnchorPoint(ccp(0.0f, 0.0f));
    //PlaceNode(titleLabel, 0.02, 0.98);
    
    CCLabelTTF* descriptionLabel = CCLabelTTF::create(description,
                                                      "Arial", SCALED_VALUE(22.0f));
    this->addChild(descriptionLabel);
    descriptionLabel->setAnchorPoint(ccp(0.0f, 0.0f));
    PlaceNode(descriptionLabel, 0.02, 0.98);
    descriptionLabel->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height);
    descriptionLabel->setColor(ccc3(204, 204, 204));
    
    titleLabel->cocos2d::CCNode::setPosition(descriptionLabel->getPositionX(),
                                             descriptionLabel->getPositionY() + descriptionLabel->getContentSize().height - 2.0f);
    
}