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


C++ CCMenu::alignItemsHorizontallyWithPadding方法代码示例

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


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

示例1: loadUI

void BYGameScene::loadUI() {
    
    CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    frameCache->addSpriteFramesWithFile("ui.plist", "ui.png");
    
    CCSize winSize    = CCDirector::sharedDirector()->getWinSize();    
    
    /// pause button
    CCSprite* btnNormalSprite = CCSprite::createWithSpriteFrameName("pause.png");
    CCMenuItemSprite *pauseMenuItem = CCMenuItemSprite::create(btnNormalSprite,
                                                               btnNormalSprite,
                                                               this,
                                                               menu_selector(BYGameScene::pauseButtonHandler));
    
    /// 2 labels for goals
    ccColor3B color = ccc3(220, 70, 20); /// red color
    _labelBotPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
    _labelBotPlayerGoalsScored->setColor(color);
    CCMenuItemLabel *labelBot = CCMenuItemLabel::create(_labelBotPlayerGoalsScored, NULL, NULL);
    labelBot->setEnabled(false);
    
    _labelTopPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
    _labelTopPlayerGoalsScored->setColor(color);
    CCMenuItemLabel *labelTop = CCMenuItemLabel::create(_labelTopPlayerGoalsScored, NULL, NULL);
    labelTop->setEnabled(false);
    
    /// CCMenu doesnt support anchorPoint as of 0x00020003 version
    CCMenu *menu = CCMenu::create(labelTop, pauseMenuItem, labelBot, NULL);
    menu->alignItemsHorizontallyWithPadding(5);
    menu->setAnchorPoint(CCPointMake(0, 0));
    menu->setPosition(CCPointMake(winSize.width - pauseMenuItem->getContentSize().width / 2,
                                  winSize.height / 2));
    menu->setRotation(90);
    this->addChild(menu);
}
开发者ID:myeyesareblind,项目名称:touchHockey,代码行数:35,代码来源:BYGameScene.cpp

示例2: showRetryButtons

void GameScene::showRetryButtons()
{
	CCMenuItemImage* retryButton = CCMenuItemImage::create(
			"ButtonRetry.png","ButtonRetry.png", this, menu_selector(GameScene::tapRetryButton));

	CCMenuItemImage* wallButton = CCMenuItemImage::create(
			"ButtonWall.png", "ButtonWall.png" , this, menu_selector(GameScene::tapWallButton));

	CCMenuItemImage* titleButton = CCMenuItemImage::create(
			"ButtonTitle.png","ButtonTitle.png", this, menu_selector(GameScene::tapTitleButton));

	CCMenu* menu = CCMenu::create(retryButton, wallButton, titleButton, NULL);
	menu->alignItemsHorizontallyWithPadding( 30.0f);
	menu->setOpacity(0);
	//menu->setPosition(ccp(m_winSize.width / 2,m_winSize.height * 1.2));
	//menu->setPosition(ccp(m_winSize.width / 2,m_winSize.height/ 4 - 10));
	this->addChild(menu,kZOrderScore,kTagMenu);

	CCFiniteTimeAction* initFade = CCFadeTo::create(0.0f,0);
	CCFiniteTimeAction* initMove = CCMoveTo::create(0.0f,ccp(m_winSize.width / 2,50.0f - 10.0f));
	CCSequence* initMix = CCSequence::createWithTwoActions(initFade,initMove);

	CCFiniteTimeAction* fade = CCFadeIn::create(1.5f);
	CCFiniteTimeAction* move = CCMoveBy::create(1.5f,ccp(0,10.0f));
	CCSpawn* mix = CCSpawn::createWithTwoActions(fade,move);
	CCActionInterval* easeMix = CCEaseIn::create( CCSequence::createWithTwoActions(initMix,mix), 2.0f);

	menu->runAction(easeMix);
}
开发者ID:yoroyorokun,项目名称:SpaceShoot,代码行数:29,代码来源:GameScene.cpp

示例3: initWithController

bool GameUI::initWithController(GameScene* controller, int chapter, int level) {
  {
    CCMenu* gameplay = CCMenu::node();
        
    {
      CCSprite* up = CCSprite::spriteWithSpriteFrameName("reset_button.png");
      CCSprite* down = CCSprite::spriteWithSpriteFrameName("reset_button_pressed.png");
      CCMenuItemSprite* restartButton = CCMenuItemSprite::itemFromNormalSprite(up, down, controller, menu_selector(GameScene::restartGame));    
      gameplay->addChild(restartButton, 0);
    }
    
    {
      CCSprite* up = CCSprite::spriteWithSpriteFrameName("pause_button.png");
      CCSprite* down = CCSprite::spriteWithSpriteFrameName("pause_button_pressed.png");
      CCMenuItemSprite* pauseButton = CCMenuItemSprite::itemFromNormalSprite(up, down, controller, menu_selector(GameScene::pauseGame));    
      gameplay->addChild(pauseButton, 0);
    }
    
    {
      BoostBar* boostBar = BoostBar::node();
      CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
      boostBar->setPosition(ccp(110, screenSize.height - 20));
      this->addChild(boostBar, boostBar->getZOrder(), TAG_BOOST);
    }
    
    {
      CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
      
      String levelString = String::withFormat("%d - %d", chapter + 1, level + 1);
      CCLabelBNFont* levelLabel = CCLabelBNFont::labelWithString(levelString.c_str(), "soupofjustice_24_white.fnt");
      levelLabel->setPosition(ccp(screenSize.width - 30, -10));
      addChild(levelLabel);
      
      CCDelayTime* delayIn = CCDelayTime::actionWithDuration(2);
      CCMoveBy* moveUp = CCMoveBy::actionWithDuration(0.4, ccp(0, 25));
      CCEaseBackOut* moveUpEase = CCEaseBackOut::actionWithAction(moveUp);
      
      CCFiniteTimeAction* sequence = CCSequence::actions(delayIn, moveUpEase, 0);
      levelLabel->runAction(sequence);
    }
    
    {
      CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
      gameplay->setPosition(ccp(screenSize.width - 50, screenSize.height - 20));
      gameplay->alignItemsHorizontallyWithPadding(-10);
      this->addChild(gameplay);
    }
  }
  
  return true;
}
开发者ID:nkostelnik,项目名称:WonderPants,代码行数:51,代码来源:GameUI.cpp

示例4: 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);
}
开发者ID:4nakin,项目名称:CutTheRope-x,代码行数:14,代码来源:HelloWorldScene.cpp

示例5: 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 );        
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:17,代码来源:LevelEditor.cpp

示例6: init

bool MapSelector::init() {
  if (!CCLayer::init()) {
    return false;
  }
  
  CCMenuItemImage* leftArrow = CCMenuItemImage::create("left_arrow.png",
                                                       "left_arrow_selected.png",
                                                       this,
                                                       menu_selector(MapSelector::leftButtonPressed));
  CCMenuItemImage* rightArrow = CCMenuItemImage::create("right_arrow.png",
                                                        "right_arrow_selected.png",
                                                        this,
                                                        menu_selector(MapSelector::rightButtonPressed));
  CCMenu* menu = CCMenu::create(leftArrow, rightArrow, NULL);
  menu->alignItemsHorizontallyWithPadding(180);
  this->addChild(menu);
  _nextMaps = NULL;
  return true;
}
开发者ID:c000,项目名称:VOXCHRONICLE,代码行数:19,代码来源:MapSelector.cpp

示例7: addFailMenu

// Add button menu to fail layer.
void GameEndLayer::addFailMenu()
{
	CCMenuItemImage* replay = CCMenuItemImage::create(nameOfRestartNormal, nameOfRestartSelect, this,
		menu_selector(GameEndLayer::onReplay));
	replay->setScale(1.5f);
	CCMenuItemImage* levels = CCMenuItemImage::create(nameOfSelectLevelNormal, nameOfSelectLevelSelect, this,
		menu_selector(GameEndLayer::onLevels));
	levels->setScale(1.5f);

	CCMenu* menu = CCMenu::create(replay, levels, NULL);
	//menu->setScale(1.5f);

	// Padding the items.
	menu->alignItemsHorizontallyWithPadding(20);

	menu->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2 ,
		CCDirector::sharedDirector()->getWinSize().height / 3));
	this->addChild(menu, 2);
}
开发者ID:xiaolizi521,项目名称:Classes,代码行数:20,代码来源:GameEndLayer.cpp

示例8: init

bool PauseLayer:: init(GameLayer *gameLayer) {
    if (!CCLayer::init()) {
        return false;
    }
    float scale = Utility::isIPad() ? 1 : 0.5;
    gLayer = gameLayer;
    charMenuIemList = new CCArray;
//    Utility::addSpriteSheet("buttonTexture");
    isCallFromRecords = true;
    
    winSize = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(50, 50, 50, 100), winSize.width  , winSize.height );
    addChild(colorLayer);
    
    if (gameLayer->sceneType == kSceneTypeGameScene) {
        addMenuItems("btnNewGame.png", 1);   
    }
    addMenuItems("btnMenu.png", 2);
    
    CCMenu *btnMenu = CCMenu::createWithArray(charMenuIemList);
    btnMenu->alignItemsHorizontallyWithPadding(winSize.width * 0.05);
    btnMenu->setPosition(ccp(winSize.width * 0.2, winSize.height * 0.1));
    addChild(btnMenu, 2);

    CCSprite *iconStar = CCSprite::createWithSpriteFrameName("coinsStars_4.png");
    iconStar->setScale(0.8);
    iconStar->setPosition(ccp(winSize.width * 0.05, winSize.height * 0.92));
    addChild(iconStar, 2);
    
    const char *totalStars = CCString::createWithFormat("%d", Utility::getTotalStars())->getCString();
    CCLabelBMFont *starsLabel = CCLabelBMFont::create(totalStars, kFontChubby, 0);
    starsLabel->setPosition(ccp(iconStar->getPositionX() + winSize.width * 0.05, winSize.height * 0.92));
    starsLabel->setScale(scale);
    addChild(starsLabel, 2);
    
    addObjectiveLayer();
    hideHUDButtons();
    //add resume button

    createButton("btnResume.png", 3, ccp(winSize.width * 0.9, winSize.height * 0.1));
//    createButton("btnSound.png", 4, ccp(winSize.width * 0.95,winSize.height * 0.92));
    return true;
}
开发者ID:ashtonjohnson,项目名称:testing_games,代码行数:43,代码来源:PauseLayer.cpp

示例9: init

bool HelpScene::init(){
	if(BaseScene::init()){
		frameCache->addSpriteFramesWithFile("Themes/scene/help_1-hd.plist");
		frameCache->addSpriteFramesWithFile("Themes/scene/help_2-hd.plist");
		frameCache->addSpriteFramesWithFile("Themes/scene/help_3-hd.plist");
		//背景图片
		CCSprite* helpBg = SPRITE(help_bg.png);
		helpBg->setPosition(VisibleRect::center());
		addChild(helpBg);

		//菜单 Home
		CCMenuItemSprite* homeBtn = CCMenuItemSprite::create(SPRITE(help_home_normal.png),
			SPRITE(help_home_pressed.png),SceneManager::shareSceneManager(),menu_selector(SceneManager::toHomeSceneFromHelp));
		CCMenu* homeMenu = CCMenu::create(homeBtn,NULL);
		homeMenu->setPosition(ccp(VisibleRect::leftTop().x+70,VisibleRect::leftTop().y-60));
		addChild(homeMenu);

		//切换菜单
		helpBtn = CCMenuItemSprite::create(SPRITE(tips_normal_CN.png),SPRITE(tips_normal_CN.png),
			SPRITE(tips_selected_CN.png),this,menu_selector(HelpScene::tabMenuHandler));
		monsterBtn = CCMenuItemSprite::create(SPRITE(monster_normal_CN.png),SPRITE(monster_normal_CN.png),
			SPRITE(monster_selected_CN.png),this,menu_selector(HelpScene::tabMenuHandler));
		towerBtn = CCMenuItemSprite::create(SPRITE(tower_normal_CN.png),SPRITE(tower_normal_CN.png),
			SPRITE(tower_selected_CN.png),this,menu_selector(HelpScene::tabMenuHandler));
		CCMenu* tabMenu = CCMenu::create(helpBtn,monsterBtn,towerBtn,NULL);
		helpBtn->setEnabled(false);
		tabMenu->alignItemsHorizontallyWithPadding(0);
		tabMenu->setPosition(ccp(VisibleRect::top().x,VisibleRect::top().y-50));
		addChild(tabMenu);

		CCLayer* tipLayer = CCLayer::create();
		CCLayer* monsterLayer = CCLayer::create();
		CCLayer* towerLayer = CCLayer::create();
		helpLayers = CCLayerMultiplex::create(tipLayer,monsterLayer,towerLayer,NULL);
		addChild(helpLayers);
		setTipLayer(tipLayer);
		setMonsterLayer(monsterLayer);
		setTowerLayer(towerLayer);
		return true;
	}
	return false;
}
开发者ID:AIRIA,项目名称:LuoBo,代码行数:42,代码来源:HelpScene.cpp

示例10: createMenu

bool SP_Main::createMenu()
{
	bool bRet = false;

	do
	{
		s = CCDirector::sharedDirector()->getWinSize();

		// 뒤로가기 버튼
		CCMenuItemImage* pBackItem = CCMenuItemImage::create("common/back_btn_2.png", "common/back_pressed_btn_2.png", this, menu_selector(SP_Main::menuClickCallback));
		pBackItem->setTag(1);

		// 다시하기 버튼
		CCMenuItemImage* pRetryItem = CCMenuItemImage::create("common/again_btn_2.png", "common/again_pressed_btn_2.png", this, menu_selector(SP_Main::menuClickCallback));
		pRetryItem->setTag(2);

		CCMenu* pMenu = CCMenu::create();
		pMenu->addChild(pBackItem);
		pMenu->addChild(pRetryItem);
		pMenu->setPosition(ccp(19 + pBackItem->getContentSize().width , s.height - 40));
		pMenu->alignItemsHorizontally();
		this->addChild(pMenu, 100);


		// 숫자, 알파벳 보기
		m_pShowNItem = CCMenuItemImage::create("common/game/sliding/number_btn.png", "common/game/sliding/number_btn_pressed.png", this, menu_selector(SP_Main::menuShow));
		m_pShowAItem = CCMenuItemImage::create("common/game/sliding/alphabet_btn.png", "common/game/sliding/alphabet_btn_pressed.png", this, menu_selector(SP_Main::menuShow));
		m_pShowNItem->setTag(0);
		m_pShowAItem->setTag(1);	

		CCMenu* pMenuShow = CCMenu::create();
		pMenuShow->addChild(m_pShowNItem);
		pMenuShow->addChild(m_pShowAItem);
		pMenuShow->alignItemsHorizontallyWithPadding(5);
		pMenuShow->setPosition(SHOWMENU_XY);
		this->addChild(pMenuShow, 1);

		bRet = true;
	} while(0);

	return bRet;
}
开发者ID:faransae,项目名称:Classes,代码行数:42,代码来源:SP_Main.cpp

示例11: init

bool TitleLayer::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}
    
    // Get window size
    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
    
    // Create text label for title of game - "@stroids" - don't sue me Atari!
    CCLabelTTF *title = CCLabelTTF::labelWithString("@stroids", "Courier", 64.0);
    
    // Position title at center of screen
    title->setPosition(ccp(windowSize.width / 2, windowSize.height/2));
    
    // Add to layer
    this->addChild(title, 1);
    
    // Set the default CCMenuItemFont font
    CCMenuItemFont::setFontName("Courier");
    
    // Create "play," "scores," and "controls" buttons - when tapped, they call methods we define: playButtonAction and scoresButtonAction
    CCMenuItemFont *playButton = CCMenuItemFont::itemFromString("play", this, menu_selector(TitleLayer::playButtonAction));
    CCMenuItemFont *scoresButton = CCMenuItemFont::itemFromString("scores", this, menu_selector(TitleLayer::scoresButtonAction));
    CCMenuItemFont *controlsButton = CCMenuItemFont::itemFromString("controls", this, menu_selector(TitleLayer::controlsButtonAction));
    
    // Create menu that contains our buttons
    CCMenu *menu = CCMenu::menuWithItems(playButton, scoresButton, controlsButton, NULL);

    // Align buttons horizontally
    menu->alignItemsHorizontallyWithPadding(20);
    
    // Set position of menu to be below the title text
    menu->setPosition(ccp(windowSize.width / 2, title->getPosition().y - title->getContentSize().height / 1.5));

    // Add menu to layer
    this->addChild(menu, 2);
        
	return true;
}
开发者ID:Hyacinth,项目名称:AsteroidsCocos2D-x,代码行数:41,代码来源:TitleLayer.cpp

示例12: init

bool GRPopLayer::init()
{
	bool bRet = false;
	do
	{
		CC_BREAK_IF(!CCLayer::init());

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

		//设置这个层的背景图片,并且设置其位置为整个屏幕的中点
		CCSprite * background = CCSprite::create("input.png");
		m_bgSprite = background;
		background->setPosition(ccp(winSize.width/2,winSize.height/2));
		this->addChild(background);

		//获得背景图片的大小
		CCSize contentSize = background->getContentSize();
		m_size = contentSize;

		//添加俩个菜单在这个层中
		CCMenuItemImage * item1 = CCMenuItemImage::create("button.png","button_pressed.png","",this,menu_selector(GRPopLayer::yesButton));
	

		CCMenu * menu = CCMenu::create(item1,NULL,NULL);
		menu->alignItemsHorizontallyWithPadding(5);
		menu->setPosition(ccp(contentSize.width/2,contentSize.height/4));

		background->addChild(menu);

		//设置题目和文本内容
		this->setContent();

		this->setTouchEnabled(true);
		bRet = true;
	}
	while(0);

	return bRet;
}
开发者ID:lulyon,项目名称:GravityTheMobileGame,代码行数:39,代码来源:GRPopLayer.cpp

示例13: ccpAdd

void MenuLayer2::alignMenusH()
{
	for(int i=0;i<2;i++) 
	{
		CCMenu *menu = (CCMenu*)getChildByTag(100+i);
		menu->setPosition( m_centeredMenu );
		if(i==0) 
		{
			// TIP: if no padding, padding = 5
			menu->alignItemsHorizontally();			
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpAdd(p, CGPointMake(0,30)) );
			
		} 
		else 
		{
			// TIP: but padding is configurable
			menu->alignItemsHorizontallyWithPadding(40);
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpSub(p, CGPointMake(0,30)) );
		}		
	}
}
开发者ID:charlesa101,项目名称:cocos2d-x,代码行数:23,代码来源:MenuTest.cpp

示例14: init

bool ControlLayer::init()
{
	if(!CCLayer::init())
	{
		return false;
	}

	//创建方向按钮
	CCMenuItem *up = CCMenuItemFont::itemWithString("up", this, menu_selector(ControlLayer::menuCallBackMove));
	CCMenuItem *down = CCMenuItemFont::itemWithString("down", this, menu_selector(ControlLayer::menuCallBackMove));
	CCMenuItem *left = CCMenuItemFont::itemWithString("left", this, menu_selector(ControlLayer::menuCallBackMove));
	CCMenuItem *right = CCMenuItemFont::itemWithString("right", this, menu_selector(ControlLayer::menuCallBackMove));
	up->setTag(kUp);
	down->setTag(kDown);
	left->setTag(kLeft);
	right->setTag(kRight);
	CCMenu *menu = CCMenu::menuWithItems(up, down, left, right, NULL);
	
	//排列按钮
	menu->alignItemsHorizontallyWithPadding(50);
	this->addChild(menu);

	return true;
}
开发者ID:Kurukshetran,项目名称:MagicTower,代码行数:24,代码来源:ControlLayer.cpp

示例15: init

bool ResultScene::init()
{
    bool result = GradientLayer::init();

    if (result) {
        setTitle(MessageResultTitle);

        CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
        GameEngine *engine = GameEngine::sharedEngine();

        CCSprite *braveImage = CCSprite::createWithSpriteFrameName("brave.png");
        braveImage->setRotation(90);
        braveImage->setPosition(ccp(windowSize.width / 2, windowSize.height - kBraveImageMarginTop - braveImage->getContentSize().height / 2));
        this->addChild(braveImage);

        CCLabelTTF *messageLabel = CCLabelTTF::create(engine->getResultMessage(), DefaultFontName, FontSizeSmall);
        messageLabel->setPosition(ccp(windowSize.width / 2 + kBraveMessageAdjustX, windowSize.height - kBraveMessageMarginTop));
        messageLabel->setAnchorPoint(ccp(0.0, 0.0));
        this->addChild(messageLabel);

        float boxBottom = kCommandAreaHeight + kCommandAreaMarginTop + kCommandAreaMarginBottom;
        CCDrawNode *boxNode = CCDrawNode::create();
        CCPoint contentBox[] = {ccp(kBoxMarginHorizontal, windowSize.height - kBoxMarginTop),
            ccp(windowSize.width - kBoxMarginHorizontal, windowSize.height - kBoxMarginTop),
            ccp(windowSize.width - kBoxMarginHorizontal, boxBottom),
            ccp(kBoxMarginHorizontal, boxBottom)};

        boxNode->drawPolygon(contentBox, 4, kBoxFillColor, 1, kBoxBorderColor);
        this->addChild(boxNode);

        CCString *scoreText = CCString::createWithFormat("%s:%d", MessageScoreText, engine->getScore());
        CCLabelTTF *scoreLabel = CCLabelTTF::create(scoreText->getCString(), DefaultFontName, FontSizeNormal);
        scoreLabel->setPosition(ccp(windowSize.width / 2, windowSize.height - kScoreLabelMarginTop));
        this->addChild(scoreLabel);

        map<hiberlite::sqlid_t, int> *foundItems = engine->getFoundItems();
        map<hiberlite::sqlid_t, int>::iterator foundItemsIterator = foundItems->begin();
        vector<Item> *items = engine->getItems();

        float itemImageAreaMarginLeft = windowSize.width / 2 - ((kNumberOfLineItems / 2 - 1) * (kItemImageSize + kItemImageMarginHorizontal)) - kItemImageMarginHorizontal / 2 - kItemImageSize / 2;

        int sumFoundItems = 0;
        int index = 0;
        while (foundItemsIterator != foundItems->end()) {
            hiberlite::sqlid_t itemID = (*foundItemsIterator).first;
            Item item = items->at(itemID - 1);
            int count = (*foundItemsIterator).second;

            const char *imageFileName = item->image.c_str();

            int posX = index % kNumberOfLineItems;
            int posY = index / kNumberOfLineItems;

            CCPoint imagePosition = ccp(itemImageAreaMarginLeft + (kItemImageSize + kItemImageMarginHorizontal) * posX,
                                        windowSize.height - kItemImageAreaMarginTop - (kItemImageSize + kItemImageMarginVertical) * posY);
            CCSprite *itemImage = CCSprite::createWithSpriteFrameName(imageFileName);
            itemImage->setPosition(imagePosition);
            this->addChild(itemImage);

            sumFoundItems += count;
            if (count > kItemCountMax) {
                count = kItemCountMax;
            }

            CCString *countText = CCString::createWithFormat("%d", count);
            CCLabelTTF *countLabel = CCLabelTTF::create(countText->getCString(), DefaultFontName, FontSizeSmall);
            countLabel->setPosition(ccpAdd(imagePosition, ccp(0, -kItemImageSize / 2 - kItemImageCountLabelAdjustY)));
            this->addChild(countLabel);

            foundItemsIterator++;
            index++;
        }

        CCString *itemCountText = CCString::createWithFormat("%s:%d", MessageNumberOfFoundItemsText, sumFoundItems);
        CCLabelTTF *itemCountLabel = CCLabelTTF::create(itemCountText->getCString(), DefaultFontName, FontSizeNormal);
        itemCountLabel->setPosition(ccp(windowSize.width / 2, windowSize.height - kItemCountLabelMarginTop));
        this->addChild(itemCountLabel);

        CCLayerColor *retryLayer = CCLayerColor::create((ccColor4B){0x00, 0x00, 0x00, 0x00}, kCommandButtonWidth, kCommandButtonHeight);
        CCLabelTTF *retryLabel = CCLabelTTF::create(MessageRetryButtonTitle, DefaultFontName, FontSizeNormal);
        retryLabel->setPosition(ccp(kCommandButtonWidth / 2, kCommandButtonHeight / 2));
        retryLayer->addChild(retryLabel);
        CCMenuItem *retryItem = CCMenuItemLabel::create(retryLayer,
                                                        GameEngine::sharedEngine(),
                                                        menu_selector(GameEngine::startNewGame));

        CCLayerColor *backTitleLayer = CCLayerColor::create((ccColor4B){0x00, 0x00, 0x00, 0x00}, kCommandButtonWidth, kCommandButtonHeight);
        CCLabelTTF *backTitleLabel = CCLabelTTF::create(MessageBackTitleButtonTitle, DefaultFontName, FontSizeNormal);
        backTitleLabel->setPosition(ccp(kCommandButtonWidth / 2, kCommandButtonHeight / 2));
        backTitleLayer->addChild(backTitleLabel);
        CCMenuItem *backTitleItem = CCMenuItemLabel::create(backTitleLayer,
                                                            GameEngine::sharedEngine(),
                                                            menu_selector(GameEngine::showTitle));

        CCMenu *menu = CCMenu::create(retryItem, backTitleItem, NULL);
        menu->alignItemsHorizontallyWithPadding(kCommandButtonPadding);
        menu->setPosition(ccp(windowSize.width / 2, kCommandAreaMarginBottom + kCommandAreaHeight / 2));
        this->addChild(menu);
    }

//.........这里部分代码省略.........
开发者ID:ichiko,项目名称:yamiHikariGame,代码行数:101,代码来源:ResultScene.cpp


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