当前位置: 首页>>代码示例>>C++>>正文


C++ CCMenuItemLabel::getContentSize方法代码示例

本文整理汇总了C++中CCMenuItemLabel::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemLabel::getContentSize方法的具体用法?C++ CCMenuItemLabel::getContentSize怎么用?C++ CCMenuItemLabel::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCMenuItemLabel的用法示例。


在下文中一共展示了CCMenuItemLabel::getContentSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initBottomMenu

bool CCLobbyView::initBottomMenu()
{
    CCDirector* director = CCDirector::sharedDirector();
    const CCSize mySize = this->getContentSize();
    const CCPoint& center = ccpMult( ccpFromSize( mySize ), 0.5f );
    
    CCLabelTTF* connectLabel = CCLabelTTF::create( "Connect", "Arial", FONT_SIZE(48) );
    CCMenuItemLabel* connectItem = CCMenuItemLabel::create( connectLabel, this, menu_selector( CCLobbyView::connectButtonCallback ) );
    
    CCLabelTTF* createLabel = CCLabelTTF::create( "Create Room", "Arial", FONT_SIZE(48) );
    CCMenuItemLabel* createItem = CCMenuItemLabel::create( createLabel, this, menu_selector( CCLobbyView::createGameButtonCallback ) );
    
    CCLabelTTF* randomLabel = CCLabelTTF::create( "Random Room", "Arial", FONT_SIZE(48) );
    CCMenuItemLabel* randomItem = CCMenuItemLabel::create( randomLabel, this, menu_selector( CCLobbyView::joinGameButtonCallback ) );
    
    pBottomMenu = CCMenu::create( connectItem, createItem, randomItem, NULL );
    if( pBottomMenu )
    {
        this->setConnectMenu( connectItem );
        this->setJoinRandomRoomMenu( randomItem );
        this->setCreateRoomMenu( createItem );
        pBottomMenu->alignItemsVerticallyWithPadding(20.0f);
        float posy = connectItem->getContentSize().height;
        posy += createItem->getContentSize().height;
        posy += randomItem->getContentSize().height;
        posy += 20.0f + 20.0f;
//        bottomMenu->alignItemsHorizontally();
        pBottomMenu->setPosition( CCPointMake( center.x, posy ) );
        this->addChild( pBottomMenu, 0, Child::CCMenu_bottomMenu );
    }
    
    return pBottomMenu;
}
开发者ID:kaznog,项目名称:t09,代码行数:33,代码来源:CCLobbyView.cpp

示例2: init

// on "init" you need to initialize your instance
bool TitleScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }

    //add the menu item for back to main menu
    int contentHeight = 0;
    int contentWidth = 0;
    m_pItemMenu = CCMenu::create();
    for (int i = 0; i < ITEM_COUNT; ++i)
    {
        CCLabelTTF* label = CCLabelTTF::create(menuItem[i].c_str(), "Arial", VisibleRect::getScaledFont(20));
        CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TitleScene::menuCallback));
        pMenuItem->setAnchorPoint(CCPointZero);
        
        contentHeight = MAX(contentHeight, pMenuItem->getContentSize().height);
        contentWidth = MAX(contentWidth, pMenuItem->getContentSize().width);
        CCLog("Height = %d", contentHeight);
        CCLog("Width = %d", contentWidth);
        
        m_pItemMenu->addChild(pMenuItem, i + 10000);
    }
    
    m_pItemMenu->setContentSize(CCSizeMake(contentWidth, (ITEM_COUNT - 1) * contentHeight));
    m_pItemMenu->setPosition(ccp( CCDirector::sharedDirector()->getWinSize().width - m_pItemMenu->getContentSize().width, m_pItemMenu->getContentSize().height));
    m_pItemMenu->alignItemsVertically();
    this->addChild(m_pItemMenu, 1);
        
    /////////////////////////////
    // 3. add your codes below...
    
    // add a label shows "Hello World"
    // create and initialize a label
//    CCLabelTTF* pLabel = CCLabelTTF::create("Title Scene", "Thonburi", VisibleRect::getScaledFont(34));
//    
//    // ask director the window size
//    CCSize size = VisibleRect::getVisibleRect().size;
//    
//    // position the label on the center of the screen
//    pLabel->setPosition( ccp(size.width / 2, size.height - VisibleRect::getScaledFont(20)) );
//    
//    // add the label as a child to this layer
//    this->addChild(pLabel, 1);
    
    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("Default.png");
    pSprite->setScale(VisibleRect::getScale());
    
    // position the sprite on the center of the screen
    pSprite->setPosition( ccp(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height/2) );
    
    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);
    
    return true;
}
开发者ID:akinlin,项目名称:ProjectDrumroll,代码行数:61,代码来源:TitleScene.cpp

示例3: init

// on "init" you need to initialize your instance
bool MainMenu::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}

	// ask director the window size
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	float scale = MultiResolution::getScale();
	/////////// Menu ////////////
	CCLabelBMFont* labelStart = CCLabelBMFont::create("Start", "futura-48.fnt");
	CCMenuItemLabel* pStartItem = CCMenuItemLabel::create(labelStart, this, menu_selector(MainMenu::menuStartCallback));
	pStartItem->setPosition(ccp(size.width/2, size.height/2));
	pStartItem->setScale(scale);

	CCLabelBMFont* labelOptions = CCLabelBMFont::create("Options", "futura-48.fnt");
	CCMenuItemLabel *pOptionsItem = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::menuOptionsCallback));
	pOptionsItem->setPosition(ccp(size.width/2, size.height/2 - pStartItem->getContentSize().height*scale));
	pOptionsItem->setScale(scale);

	CCLabelBMFont* labelExit = CCLabelBMFont::create("Exit", "futura-48.fnt");
	CCMenuItemLabel *pExitItem = CCMenuItemLabel::create(labelExit, this, menu_selector(MainMenu::menuCloseCallback));
	pExitItem->setPosition(ccp(size.width/2, size.height/2 - 2*pStartItem->getContentSize().height*scale));
	pExitItem->setScale(scale);

	CCMenu* pMenu = CCMenu::create(pStartItem, pOptionsItem, pExitItem, NULL);
	pMenu->setPosition( CCPointZero );
	this->addChild(pMenu, 1);
	/////////////////////////////

	//////////// Game title and background image  ////////////
	CCLabelBMFont* pLabel = CCLabelBMFont::create("Crack Code", "futura-48.fnt");

	// position the label on the center of the screen
	pLabel->setPosition( ccp(size.width / 2, size.height - 50*scale) );
	pLabel->setScale(scale+0.3);

	// add the label as a child to this layer
	this->addChild(pLabel, 1);

	// add "MainMenu" splash screen"
	CCSprite* pSprite = CCSprite::create("safe_background.jpg");

	// position the sprite on the center of the screen
	pSprite->setPosition( ccp(size.width / 2, size.height / 2) );

	// add the sprite as a child to this layer
	this->addChild(pSprite, 0);
	//////////////////////////////////////////////////////////

	return true;
}
开发者ID:TigranOg,项目名称:CrackCode,代码行数:56,代码来源:MainMenuScene.cpp

示例4: init

bool NovelScene::init()
{
    if (!CCLayer::init())
    {
        return false;
    }
       
    this->setTouchEnabled(true);
    this->setTouchMode(kCCTouchesOneByOne);
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
    CCSprite* background = CCSprite::create("013-PostTown01.jpg");
    background->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    this->addChild(background, kZOrder_Background, kTag_Background);
        
    CCLayerColor * textLayer = CCLayerColor::create(ccc4(0, 0, 0, 255 * 0.7), winSize.width, winSize.height * 0.25);
    textLayer->setPosition(CCPointZero);
    this->addChild(textLayer, kZOrder_TextLayer, kTag_TextLayer);
    
    CCString* string = CCString::createWithFormat("w = %f.1 h = %f.1 f = %f", winSize.width, winSize.height, BASE_FONT_SIZE);
    CCLog("%s", string->getCString());
    
    CCLabelTTF* textLabel = CCLabelTTF::create(string->getCString(), "", BASE_FONT_SIZE);
    textLabel->setAnchorPoint(ccp(0, 0));
    textLabel->setColor(ccWHITE);
    textLabel->setPosition(ccp(BASE_FONT_SIZE, textLayer->getContentSize().height - textLabel->getContentSize().height - BASE_FONT_SIZE));
    textLayer->addChild(textLabel, kZOrder_TextLayer, kTag_TextLayer_textLabel);

    CCLayerColor * nameTextLayer = CCLayerColor::create(ccc4(0, 0, 0, 255 * 0.7), winSize.width * 0.4, winSize.height * 0.1);
    nameTextLayer->setPosition(ccp(textLayer->getPositionX(), textLayer->getPositionY() + textLayer->getContentSize().height + nameTextLayer->getContentSize().height * 0.05));
    
	this->addChild(nameTextLayer, kZOrder_TextLayer, kTag_TextLayer_name);

    CCLabelTTF* nameTextLabel = CCLabelTTF::create("시스템 메세지", "", BASE_FONT_SIZE);
    nameTextLabel->setAnchorPoint(ccp(0, 0));
    nameTextLabel->setColor(ccGREEN);
    nameTextLabel->setPosition(ccp(BASE_FONT_SIZE, nameTextLayer->getContentSize().height - nameTextLabel->getContentSize().height - BASE_FONT_SIZE * 0.5));    
    nameTextLayer->addChild(nameTextLabel, kZOrder_TextLayer, kTag_TextLayer_nameTextLabel);
    
    CCLabelTTF* logButtonLabel = CCLabelTTF::create("Log", "Arial", BASE_FONT_SIZE);
    CCMenuItemLabel* logButtonMenuItem = CCMenuItemLabel::create(logButtonLabel, this, menu_selector(NovelScene::logMenuSelectCallback));
    logButtonMenuItem->setPosition(ccp(winSize.width * 0.95, logButtonMenuItem->getContentSize().height));
    
    CCMenu* pMenu = CCMenu::create(logButtonMenuItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, kZOrder_MenuItem, kTag_MenuItem_log);
    
    return true;
}
开发者ID:pdpdds,项目名称:cocos2dx-dev,代码行数:50,代码来源:NovelScene.cpp

示例5: init

bool PauseLayer::init()
{
    // ccc4的最后一个参数才是透明度
    if (!CCLayerColor::initWithColor(ccc4(0, 0, 0, 100))) {
        return  false;
	}

	CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -128, true);




	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	CCMenuItemImage *play = CCMenuItemImage::create("play.png", "play.png", this, menu_selector(PauseLayer::doResume));
	play->setScale(3);
	play->setPosition(ccp(winSize.width/2, winSize.height/2));

	//
	CCLabelBMFont *backLb = CCLabelBMFont::create("Main Layer", s_font);
	CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(PauseLayer::gotoSartLayer));
	goBack->setScale(0.6f);
	goBack->setPosition(ccp(winSize.width/2, goBack->getContentSize().height));

	mMenu = CCMenu::create(play, goBack, NULL);
	mMenu->setAnchorPoint(ccp(0, 0));
	addChild(mMenu, 1, 10);
	mMenu->setPosition(CCPointZero);

	mMenu->runAction(CCSequence::create(
		CCDelayTime::create(0.01f), 
		CCCallFunc::create(this, callfunc_selector(PauseLayer::schedule_menuPriority)),
		NULL));
    
    return true;
}
开发者ID:SongCF,项目名称:game-MoonWarriors,代码行数:36,代码来源:PauseLayer.cpp

示例6: addStatsLayer

void PauseLayer::addStatsLayer() {
    statsLayer = CCLayer::create();
    statsLayer->setPosition(ccp(winSize.width * 0, winSize.height * 0));
    float scale = Utility::isIPad() ? 1 : 0.7;
    CCLabelBMFont *labelObj = CCLabelBMFont::create("stats", kFontChubby, 0);
    labelObj->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.93));
    labelObj->setScale(scale);
    statsLayer->addChild(labelObj, 2);
    
    CCLabelBMFont *thisGameLabel = CCLabelBMFont::create("this game", kFontChubby, 0);
    thisGameLabel->setScale(scale);
    thisGameItem = CCMenuItemLabel::create(thisGameLabel, this, menu_selector(PauseLayer::menuCallBack) );
    thisGameItem->setContentSize(CCSize(thisGameItem->getContentSize() * scale));
    thisGameItem->setTag(7);
    
    CCLabelBMFont *slashLabel = CCLabelBMFont::create("/", kFontChubby, 0);
    slashLabel->setScale(scale);
    CCMenuItemLabel *slashItem = CCMenuItemLabel::create(slashLabel, this, menu_selector(PauseLayer::menuCallBack) );
    slashItem->setContentSize(CCSize(slashItem->getContentSize() * scale));
    
    CCLabelBMFont *recordsLabel = CCLabelBMFont::create("records", kFontChubby, 0);
    recordsLabel->setScale(scale);
    recordsItem = CCMenuItemLabel::create(recordsLabel, this, menu_selector(PauseLayer::menuCallBack) );
    recordsItem->setContentSize(CCSize(recordsItem->getContentSize() * scale));
    recordsItem->setTag(8);

    
    CCMenu *thisGameRecordsMenu = CCMenu::create(thisGameItem, slashItem, recordsItem, NULL);
    thisGameRecordsMenu->alignItemsHorizontallyWithPadding(winSize.width * 0.01);
    thisGameRecordsMenu->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.8));
    statsLayer->addChild(thisGameRecordsMenu, 2);
    
    createButton("btnObj.png", 6, ccp(winSize.width * 0.30, winSize.height * 0.93));
    const char *score = NULL;
    const char *distance = NULL;
    const char *wallsSmashed = NULL;
    const char *tightSqueezes = NULL;
    const char *longestGamePlayed = NULL;
    if (isCallFromRecords) {
        CCSprite *coinSprite = CCSprite::createWithSpriteFrameName("coin_0.png");
        coinSprite->setPosition(ccp(winSize.width * 0.75, winSize.height * 0.65));
        statsLayer->addChild(coinSprite, 2);
        
        const char *totalCoins = CCString::createWithFormat("%d", gLayer->coinScore)->getCString();
        createLabelForStats("", totalCoins, ccp(coinSprite->getPositionX() + winSize.width * 0.05, coinSprite->getPositionY()), statsLayer);
        
        score =  CCString::createWithFormat("%d", gLayer->score)->getCString();
        distance =  CCString::createWithFormat("%d meters", gLayer->distance)->getCString();
        wallsSmashed =  CCString::createWithFormat("%d", gLayer->wallSmashed)->getCString();
        tightSqueezes =  CCString::createWithFormat("%d", Utility::getTotalTightSqueezes())->getCString();
        longestGamePlayed = CCString::createWithFormat("%02dm%02ds", gLayer->minute, gLayer->seconds)->getCString();
    } else {
        const char *playerName = CCString::createWithFormat("(%s)", Utility::getPlayerName(0)->getCString())->getCString();
        createLabelForStats("", playerName, ccp(winSize.width * 0.65, winSize.height * 0.65), statsLayer);
        int longestGame = Utility::getLongestGame();
        int min = longestGame / 60;
        int sec = longestGame % 60;
        longestGamePlayed = CCString::createWithFormat("%02dm%02ds", min, sec)->getCString();
        score =  CCString::createWithFormat("%d", Utility::getPlayerScore(0))->getCString();
        distance =  CCString::createWithFormat("%d meters", Utility::getLongestDistance())->getCString();
        wallsSmashed =  CCString::createWithFormat("%d", Utility::getTotalWallSmashedLifeTime())->getCString();
        tightSqueezes =  CCString::createWithFormat("%d", Utility::getTotalTightSqueezesLifeTime())->getCString();
    }         
        createLabelForStats("score:", score, ccp(winSize.width * 0.55, winSize.height * 0.65), statsLayer);
        createLabelForStats("distance:", distance, ccp(winSize.width * 0.55, winSize.height * 0.55), statsLayer);
        createLabelForStats("walls smashed:", wallsSmashed, ccp(winSize.width * 0.55, winSize.height * 0.45), statsLayer);
        createLabelForStats("tight squeezes:", tightSqueezes, ccp(winSize.width * 0.55, winSize.height * 0.35), statsLayer);
        createLabelForStats("game time:", longestGamePlayed, ccp(winSize.width * 0.55, winSize.height * 0.25), statsLayer);
    
        addChild(statsLayer, 1);
    
}
开发者ID:ashtonjohnson,项目名称:testing_games,代码行数:72,代码来源:PauseLayer.cpp

示例7: 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;
}
开发者ID:kaznog,项目名称:t09,代码行数:48,代码来源:CCLobbyView.cpp


注:本文中的CCMenuItemLabel::getContentSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。