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


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

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


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

示例1: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    CCLog("visible size - x: %f, y: %f",visibleSize.width, visibleSize.height);
    CCLog("origin - x: %f, y: %f", origin.x, origin.y);
    
    //KYULING: 게임 메뉴로 출력할 메뉴 아이템 생성
    CCMenuItemLabel *startLabel = CCMenuItemLabel::create(CCLabelTTF::create("Game start", "Arial", 18), this, menu_selector(HelloWorld::gameStartMenuTapped));
    CCMenuItemLabel *optionLabel = CCMenuItemLabel::create(CCLabelTTF::create("Game Option", "Arial", 18), this, menu_selector(HelloWorld::gameOptionMenuTapped));
    
    //게임 메뉴 생성
    CCMenu *gameMenu = CCMenu::create(startLabel, optionLabel, NULL);
    gameMenu->alignItemsVerticallyWithPadding(20);
    this->addChild(gameMenu);
    
    return true;
}
开发者ID:KyulingLee,项目名称:PentaBingo,代码行数:27,代码来源:HelloWorldScene.cpp

示例2: init

bool MenuLayer::init(GameplayView* view)
{
	bool bRet = false;
	do 
	{
		_parent = view;

		int fontSize = 32;
		CCString* fontName = CCString::create("Thonburi");

		CCMenuItemLabel* resume = CCMenuItemLabel::create(CCLabelTTF::create("Resume", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::resume));
		
		CCMenu* menu = CCMenu::create(resume, NULL);
		menu->alignItemsVerticallyWithPadding(10);
		addChild(menu);

		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		CCLabelTTF* gameover = CCLabelTTF::create("Game Over", "American Typewriter", 64);
		addChild(gameover);
		gameover->setColor(ccc3(126, 126, 126));
		gameover->setPosition(ccp(winSize.width*0.5,winSize.height*0.5 + 84));

		_scoreLabel = CCLabelTTF::create("60", "American Typewriter", 16);
		addChild(_scoreLabel);
		_scoreLabel->setColor(ccc3(126, 126, 126));
		_scoreLabel->setPosition(ccp(winSize.width*0.5,winSize.height*0.5 + 32));

		bRet = true;
	} while (0);
	return bRet;
}
开发者ID:woodpecker-3,项目名称:bear-game,代码行数:31,代码来源:MenuLayer.cpp

示例3: QuestionContainerSprite

bool Bug458Layer::init()
{
    if(BugsTestBaseLayer::init())
    {
		// ask director the the window size
        CCSize size = CCDirector::sharedDirector()->getWinSize();

        QuestionContainerSprite* question = new QuestionContainerSprite();
        QuestionContainerSprite* question2 = new QuestionContainerSprite();
        question->init();
        question2->init();

//		[question setContentSize:CGSizeMake(50,50)];
//		[question2 setContentSize:CGSizeMake(50,50)];
		
        CCMenuItemSprite* sprite = CCMenuItemSprite::itemFromNormalSprite(question2, question, this, menu_selector(Bug458Layer::selectAnswer));
        CCLayerColor* layer = CCLayerColor::layerWithColorWidthHeight(ccc4f(0,0,255,255), 100, 100);
		question->release();
		question2->release();

        CCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight(ccc4f(255,0,0,255), 100, 100);
        CCMenuItemSprite* sprite2 = CCMenuItemSprite::itemFromNormalSprite(layer, layer2, this, menu_selector(Bug458Layer::selectAnswer));        
        CCMenu* menu = CCMenu::menuWithItems(sprite, sprite2, NULL);
        menu->alignItemsVerticallyWithPadding(100);
        menu->setPosition(ccp(size.width / 2, size.height / 2));

		// add the label as a child to this Layer
		addChild(menu);

        return true;
	}
	return false;
}
开发者ID:ccjimmy,项目名称:TweeJump4wp8,代码行数:33,代码来源:Bug-458.cpp

示例4: init

// on "init" you need to initialize your instance
bool HelpScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *background = CCSprite::create("title_help.png");
    background->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    this->addChild(background);
    
    CCMenuItemImage *backButton = CCMenuItemImage::create("back_button.png", "back_button.png", this, menu_selector(HelpScene::BackPressed));
    
    CCMenu *mainMenu = CCMenu::create(backButton, NULL);
    mainMenu->alignItemsVerticallyWithPadding(screenSize.height * 0.03f);
    mainMenu->setPosition(ccp(screenSize.width * 0.75f, screenSize.height * 0.1f));
    
    this->addChild(mainMenu);
    
    return true;
}
开发者ID:JustinMackenzie,项目名称:Shoveller2,代码行数:26,代码来源:HelpScene.cpp

示例5: init

bool GameOverLayer::init()
{
	if ( CCLayerColor::initWithColor( ccc4(255,255,255,255) ) )
	{
		// Get window size and place the label upper. 
		CCSize size = CCDirector::sharedDirector()->getWinSize();

		// 3. Add add a splash screen, show the cocos2d splash image.
		CCSprite* pSprite = CCSprite::create("IntroScene.png");
		if(!pSprite)
			return false;

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

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

		//Add the menu choice
		CCMenuItemFont::setFontSize( 100 );
		CCMenuItemFont::setFontName("Courier New");
		CCLabelBMFont* labelNew = CCLabelBMFont::create("Restart Game!", "bitmapFontTest3.fnt");
		CCMenuItemLabel* itemNew = CCMenuItemLabel::create(labelNew, this, menu_selector(GameOverLayer::menuRestartCallback));

		CCLabelBMFont* labelQuit = CCLabelBMFont::create("Quit", "bitmapFontTest3.fnt");
		CCMenuItemLabel* itemQuit = CCMenuItemLabel::create(labelQuit, this, menu_selector(GameOverLayer::menuCloseCallback));

		CCMenu* menu = CCMenu::create( itemNew, itemQuit, NULL);
		menu->alignItemsVerticallyWithPadding(50);

		int i=0;
		CCNode* child;
		CCArray * pArray = menu->getChildren();
		CCObject* pObject = NULL;
		CCARRAY_FOREACH(pArray, pObject)
		{
			if(pObject == NULL)
				break;

			child = (CCNode*)pObject;

			CCPoint dstPoint = child->getPosition();
			int offset = (int) (size.width/2 + 50);
			if( i % 2 == 0)
				offset = -offset;

			child->setPosition( ccp( dstPoint.x + offset, dstPoint.y) );
			child->runAction( 
				CCEaseElasticOut::create(CCMoveBy::create(2, ccp(dstPoint.x - offset,0)), 0.35f) 
				);
			i++;
		}

		addChild(menu);
		menu->setPosition(ccp(size.width/2, size.height/2));

		EntityManager::GetInstance()->SetGameOver(false);

		return true;
	}
开发者ID:darioslave1,项目名称:Cyber_Hackman,代码行数:60,代码来源:GameOverScene.cpp

示例6: init

KDbool OverScene::init ( KDvoid )
{
	if ( !CCLayer::init ( ) )
	{
		return KD_FALSE;
	}

	CCMenuItemFont::setFontSize ( 32 );
	CCMenuItemFont::setFontName ( "Arial.ttf" );

	CCLayerColor*	pLayer = CCLayerColor::create ( ccc4 ( 32, 32, 32, 255 ) );
	this->addChild ( pLayer, 1 ); 

	m_pTopScore = CCLabelTTF::create ( "0", "Arial.ttf", 32 );
	this->addChild ( m_pTopScore, 3 );
	m_pTopScore->setColor ( ccc3 ( 255, 0, 0 ) );
	m_pTopScore->setPosition ( ccp ( 160, 370 - 50 ) );	

	m_pScore = CCLabelTTF::create ( "0", "Arial.ttf", 32 );
	this->addChild ( m_pScore, 3 );
	m_pScore->setColor ( ccc3 ( 0, 0, 255 ) );
	m_pScore->setPosition ( ccp ( 160, 320 - 40 ) );	

	CCMenuItemFont*		pReStart = CCMenuItemFont::create ( "RESTART", this, menu_selector ( OverScene::onReStart ) );
	pReStart->setColor ( ccc3 ( 0x00, 0xCC, 0x00 ) );

	CCMenu*				pMenu = CCMenu::create ( pReStart, KD_NULL );	
	pMenu->setPosition ( ccpMid ( m_tContentSize ) );
	pMenu->alignItemsVerticallyWithPadding ( 20.0f );
	this->addChild ( pMenu, 2 );

	return KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:33,代码来源:OverScene.cpp

示例7: initLayer

bool LayerMainMenu::initLayer()
{
	bool bRet = false;

	do
	{
		CCMenuItemFont *pPlayItem = CCMenuItemFont::create( LuaHelper::s_getStringVar("TEXT_PLAY").c_str(), this, menu_selector(LayerMainMenu::onPlay));
		CC_BREAK_IF(! pPlayItem);

		CCMenuItemFont *pQuitItem = CCMenuItemFont::create( LuaHelper::s_getStringVar("TEXT_QUIT").c_str(), this, menu_selector(LayerMainMenu::onQuit));
		CC_BREAK_IF(! pQuitItem);

		CCMenu* pMenu = CCMenu::create( pPlayItem, pQuitItem, NULL );
		CC_BREAK_IF(! pMenu);
		pMenu->alignItemsVerticallyWithPadding( 100.0f );

		addChild( pMenu );

		CCSize s = CCDirector::sharedDirector()->getWinSize();
		pMenu->setPosition(ccp(s.width/2, s.height/2));

		setKeypadEnabled(true);

		bRet = true;
	}
	while( false );

	return bRet;
}
开发者ID:Bazingaaa,项目名称:ProjG,代码行数:29,代码来源:LayerMainMenu.cpp

示例8: init

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

    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *background = CCSprite::create("MainMenuBackground.png");
    background->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    this->addChild(background);
    
    CCMenuItemImage *playButton = CCMenuItemImage::create("PlayButton.png", "PlayButton.png", this, menu_selector(HelloWorld::PlayPressed));
    
    CCMenuItemImage *helpButton = CCMenuItemImage::create("HelpButton.png", "HelpButton.png", this, menu_selector(HelloWorld::HelpPressed));
    
    CCMenu *mainMenu = CCMenu::create(playButton, helpButton, NULL);
    mainMenu->alignItemsVerticallyWithPadding(screenSize.height * 0.03f);
    mainMenu->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.3f));
    
    this->addChild(mainMenu);
    
    SimpleAudioEngine::sharedEngine()->playBackgroundMusic("mainMenuMusic.mp3", true);
    
    return true;
}
开发者ID:JustinMackenzie,项目名称:Shoveller2,代码行数:30,代码来源:HelloWorldScene.cpp

示例9: makeLabels

void GameClearPopup::makeLabels()
{
    //背景
    CCSprite* frame = CCSprite::createWithSpriteFrameName(PNG_POPUP_BG2);
    frame->setScale(2.5f);
    frame->setPosition(GHelper::convI720toCC(g_visibleSize.width / 2, g_visibleSize.height / 2));
    this->addChild(frame);

    //タイトル
    CCString *s = NULL;
    if (UserSettings::getSelectedLevel() >= 15) {
    	s = CCString::create("All Clear!");
	} else {
		s = CCString::create("You Win!");
	}
    CCLabelBMFont* title = CCLabelBMFont::create(s->getCString(), FONT_YELLOW);
    title->setScale(0.6);
    title->setPosition( GHelper::convI720toCC(g_visibleSize.width * 0.5, g_visibleSize.height * 0.3));
    this->addChild(title);

    //女の子
    CCSprite *obj = CCSprite::createWithSpriteFrameName(PNG_MINI2_1);
    obj->setPosition(GHelper::convI720toCC(g_visibleSize.width * 0.5, g_visibleSize.height * 0.35));
    obj->runAction(Animations::winMiniAnimation());
    this->addChild(obj);

    //Next Stage?
    if (UserSettings::getSelectedLevel() >= 15) {
    	s = CCString::create("");
	} else {
		s = CCString::create("Next Stage?");
	}
    CCLabelBMFont* disc1 = CCLabelBMFont::create(s->getCString(), FONT_GREEN);
    disc1->setScale(0.5);
    CCMenuItemLabel* item1 = CCMenuItemLabel::create(disc1, this, menu_selector(GameClearPopup::onTapNextStage));

    //Again?
    CCLabelBMFont* disc2 = CCLabelBMFont::create("Again?", FONT_WHITE);
    disc2->setScale(0.5);
    CCMenuItemLabel* item2 = CCMenuItemLabel::create(disc2, this, menu_selector(GameClearPopup::onTapAgain));

    //Menu
    CCLabelBMFont* disc3 = CCLabelBMFont::create("Menu", FONT_WHITE);
    disc3->setScale(0.5);
    CCMenuItemLabel* item3 = CCMenuItemLabel::create(disc3, this, menu_selector(GameClearPopup::onTapMenu));

    //Quit
    CCLabelBMFont* disc4 = CCLabelBMFont::create("Quit", FONT_WHITE);
    disc4->setScale(0.5);
    CCMenuItemLabel* item4 = CCMenuItemLabel::create(disc4, this, menu_selector(GameClearPopup::onTapQuit));

    CCMenu* menu = CCMenu::create( item1, item2, item3, item4, NULL );
    menu->setTouchPriority(-128);
    menu->alignItemsVerticallyWithPadding(1.0);
    menu->setPosition(ccp(g_visibleSize.width / 1.5, g_visibleSize.height / 2 - 50));
    this->addChild(menu);
}
开发者ID:sakurabird,项目名称:cocos2dx-BlockShooting,代码行数:57,代码来源:GameClearPopup.cpp

示例10: init

// Initialize the menu items, background, and overall setup of the main menu
//
// return - false if there was an error in initializing, true otherwise
bool MainMenu::init()
{
    CCLabelTTF*      labelSinglePlayer; // the text for single player menu item
    CCLabelTTF*      labelMultiplayer;  // the text for multiplayer menu item
    CCLabelTTF*      labelOptions;      // the text for options menu item
    CCMenuItemLabel* itemSinglePlayer;  // menu item for starting single player game
    CCMenuItemLabel* itemMultiplayer;   // menu item for starting multiplayer game
    CCMenuItemLabel* itemOptions;       // menu item for opening up options
    CCMenu*          menu;              // menu to contain the menu items

    CCSize           size;              // the size of the window
    CCSprite*        background;        // the background splashscreen

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

    // get the window size from the director
    size = CCDirector::sharedDirector()->getWinSize();

    // create the text for the menu items
    labelSinglePlayer = CCLabelTTF::create("Start Single Player", FONT_STYLE, Font_Size_Default);
    labelMultiplayer  = CCLabelTTF::create("Start Multiplayer", FONT_STYLE, Font_Size_Default);
    labelOptions      = CCLabelTTF::create("Options", FONT_STYLE, Font_Size_Default);

    // add shadows to the labels, so they will be easier to read against the background
    labelSinglePlayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
    labelMultiplayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
    labelOptions->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);

    // create the items for the menu
    itemSinglePlayer = CCMenuItemLabel::create(labelSinglePlayer, this, menu_selector(MainMenu::HandleSinglePlayerPressed));
    itemMultiplayer  = CCMenuItemLabel::create(labelMultiplayer, this, menu_selector(MainMenu::HandleMultiplayerPressed));
    itemOptions      = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::HandleOptionsPressed));

    // set the color of the menu items
    itemSinglePlayer->setColor(MENU_COLOR);
    itemMultiplayer->setColor(MENU_COLOR);
    itemOptions->setColor(MENU_COLOR);

    // create menu to contain the menu items
    menu = CCMenu::create(itemSinglePlayer, itemMultiplayer, itemOptions, NULL);
    menu->alignItemsVerticallyWithPadding(MENU_ITEM_PADDING);
    menu->setPosition(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN);
    addChild(menu, 1);

    // add splash screen as a sprite on the center of the screen
    background = CCSprite::create(BACKGROUND_IMAGE);
    background->setScale(size.height / background->boundingBox().size.height);
    background->setPosition( ccp(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN) );
    addChild(background, 0);

    return true;
}
开发者ID:Rykkata,项目名称:483w,代码行数:58,代码来源:MainMenuScene.cpp

示例11: init

bool InterfaceRenderer::init() {
    if( !CCLayer::init() )
        return false;
    
    CCSize designResolutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
    
    CCLabelTTF* label = CCLabelTTF::create("분당우리교회 청년2부 행복나무", "Arial", 100);
    label->setAnchorPoint(ccp(0.5f, 1));
    label->setPosition(ccp(designResolutionSize.width/2, designResolutionSize.height-label->getDimensions().height));
    this->addChild(label);
    
//    {
//        editbox = CCEditBox::create(CCSizeMake(800, 100), CCScale9Sprite::create("green_edit.png"));
//        editbox->retain();
//        editbox->setPosition(ccp(designResolutionSize.width/2, 10));
//        editbox->setAnchorPoint(ccp(0.5f, 0));
//        editbox->setPlaceHolder("테스트용 단어를 입력해주세요.");
//        editbox->setFont("Arial", 60);
//        editbox->setFontColor(ccBLACK);
//        this->addChild(editbox);
//    }
    
    CCMenuItemFont::setFontSize(80);
    CCMenuItemFont::setFontName("Arial");
 
    // for test button
//    {
//        CCMenuItemFont* item = CCMenuItemFont::create("Add", this, menu_selector(InterfaceRenderer::onTouchedDone));
//        item->setAnchorPoint(ccp(0, 0));
//        item->setPosition(ccp(editbox->getContentSize().width+10, 0));
//        
//        CCMenuItemFont* printItem = CCMenuItemFont::create("Print", this, menu_selector(InterfaceRenderer::onTouchedPrint));
//        printItem->setAnchorPoint(ccp(0, 0));
//        printItem->setPosition(ccp(editbox->getContentSize().width+10*2+item->boundingBox().size.width, 0));
//        
//        CCMenu* menu = CCMenu::create(item,printItem,NULL);
//        menu->setPosition(ccp(0, 0));
//        menu->setAnchorPoint(ccp(0, 0));
//        editbox->addChild(menu);
//    }
    
    
    // for menually refresh button
    {
        CCMenuItemFont* item1 = CCMenuItemFont::create("requestWord", this, menu_selector(InterfaceRenderer::onTouchedRequestWord));
        CCMenuItemFont* item2 = CCMenuItemFont::create("requestMistake", this, menu_selector(InterfaceRenderer::onTouchedRequestMistake));
        
        CCMenu* menu = CCMenu::create(item1, item2, NULL);
        menu->alignItemsVerticallyWithPadding(10);
        this->addChild(menu);
    }
    
    return true;
}
开发者ID:GoodMorningCody,项目名称:WordTree,代码行数:54,代码来源:InterfaceRenderer.cpp

示例12: createStadionMenu

CCMenu* StadionLayer::createStadionMenu()
{
    CCMenuItemSprite* pause = sgl_SpriteFactory.createMenuItemSprite("btnPause.png", "btnPausePressed.png",menu_selector(StadionLayer::onPause), this);
    CCMenuItemSprite* help = sgl_SpriteFactory.createMenuItemSprite("btnHelp.png", "btnHelp.png",menu_selector(StadionLayer::onHelp), this);
    
    CCMenu* menu = CCMenu::create(pause, help, NULL);
    
    menu->alignItemsVerticallyWithPadding(2);
    menu->setPosition(ccp(32,60));
    
    return menu;
}
开发者ID:koboldul,项目名称:Football,代码行数:12,代码来源:StadionLayer.cpp

示例13: CCSizeMake

//------------------------------------------------------------------
//
// LabelTTFTest
//
//------------------------------------------------------------------
LabelTTFTest::LabelTTFTest()
{
    CCSize blockSize = CCSizeMake(200, 160);
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
    colorLayer->setAnchorPoint(ccp(0,0));
    colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2));

    this->addChild(colorLayer);

    CCMenuItemFont::setFontSize(30);
    CCMenu *menu = CCMenu::create(
        CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)),
        CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)),
        CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)),
        NULL);
    menu->alignItemsVerticallyWithPadding(4);
    menu->setPosition(ccp(50, s.height / 2 - 20));
    this->addChild(menu);

    menu = CCMenu::create(
        CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)),
        CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)),
        CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)),
        NULL);
    menu->alignItemsVerticallyWithPadding(4);
    menu->setPosition(ccp(s.width - 50, s.height / 2 - 20));
    this->addChild(menu);

    m_plabel = NULL;
    m_eHorizAlign = kCCTextAlignmentLeft;
    m_eVertAlign = kCCVerticalTextAlignmentTop;

    this->updateAlignment();
}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:41,代码来源:LabelTest.cpp

示例14: init

bool MainMenuBtnLayer::init()
{
    bool bRet = false;
    do
    {
        // Super init first
        CC_BREAK_IF(!CCLayer::init());

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


        CCImage menufile;
        menufile.initWithImageFile("Buttons.png");
        CCTexture2D *menuTexture = new CCTexture2D();
        menuTexture->initWithImage(&menufile);

        CCMenuItemSprite *startgameitem = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(6, 2, 166, 28)),
                                          CCSprite::createWithTexture(menuTexture, CCRectMake(6, 35, 166, 28)),
                                          CCSprite::createWithTexture(menuTexture, CCRectMake(6, 70, 166, 28)),
                                          this, menu_selector (MainMenuBtnLayer::menucallback));
        startgameitem->setTag(MAINMENU_ID_START);
        CCMenuItemSprite *settings = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(188, 2, 166, 28)),
                                     CCSprite::createWithTexture(menuTexture, CCRectMake(188, 35, 166, 28)),
                                     CCSprite::createWithTexture(menuTexture, CCRectMake(188, 70, 166, 28)),
                                     this, menu_selector (MainMenuBtnLayer::menucallback));
        settings->setTag(MAINMENU_ID_SETTING);
        CCMenuItemSprite *about = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(370, 2, 166, 28)),
                                  CCSprite::createWithTexture(menuTexture, CCRectMake(370, 35, 166, 28)),
                                  CCSprite::createWithTexture(menuTexture, CCRectMake(370, 70, 166, 28)),
                                  this, menu_selector (MainMenuBtnLayer::menucallback));
        about->setTag(MAINMENU_ID_ABOUT);
        CCMenuItemSprite *quit = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(552, 2, 166, 28)),
                                 CCSprite::createWithTexture(menuTexture, CCRectMake(552, 35, 166, 28)),
                                 CCSprite::createWithTexture(menuTexture, CCRectMake(552, 70, 166, 28)),
                                 this, menu_selector (MainMenuBtnLayer::menucallback));
        quit->setTag(MAINMENU_ID_QUIT);

        CCMenu *menu = CCMenu::create(startgameitem, settings, about, quit, NULL);
        menu->alignItemsVerticallyWithPadding(10);
        menu->setPosition(ccp(size.width * 0.5f, size.height * 0.5f));
        this->addChild(menu);

        bRet = true;

    } while(0);

    return bRet;
}
开发者ID:Ken93,项目名称:Simple2dShooter,代码行数:48,代码来源:MainMenuBtnLayer.cpp

示例15: init

// on "init" you need to initialize your instance
bool StartMenu::init()
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(! CCLayer::init());

		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		
		CCSprite *background = CCSprite::create(s_bg);
		background->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		addChild(background, 0);

		CCSprite* newGameNormal = CCSprite::create(s_play);
		CCSprite* newGameSelected = CCSprite::create(s_play);
		CCSprite* newGameDisabled = CCSprite::create(s_play);

		CCSprite* gameSettingNormal = CCSprite::create(s_option);
		CCSprite* gameSettingNSelected = CCSprite::create(s_option);
		CCSprite* gameSettingDesabled = CCSprite::create(s_option);

		CCSprite* exitNormal = CCSprite::create(s_exit);
		CCSprite* exitSelected = CCSprite::create(s_exit);
		CCSprite* exitDesabled = CCSprite::create(s_exit);

		CCMenuItemSprite* newGame = CCMenuItemSprite::create(newGameNormal, newGameSelected, newGameDisabled, this, menu_selector(StartMenu::menuCallback));
		CCMenuItemSprite* gameSetting = CCMenuItemSprite::create(gameSettingNormal, gameSettingNSelected, gameSettingDesabled, this, menu_selector(StartMenu::menuCallback));
		CCMenuItemSprite* exit = CCMenuItemSprite::create(exitNormal, exitSelected, exitDesabled, this, menu_selector(StartMenu::menuCallback));

		newGame->setTag(0);
		gameSetting->setTag(1);
		exit->setTag(2);

		CCMenu* menu = CCMenu::create(newGame, gameSetting, exit, NULL);
		menu->alignItemsVerticallyWithPadding(20);
		this->addChild(menu);
		menu->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		//this->schedule(schedule_selector(StartMenu::update), 0.1);


		bRet = true;
    } while (0);

    return bRet;
}
开发者ID:huanghuiquan,项目名称:TomAndJerry,代码行数:46,代码来源:StartMenu.cpp


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