Add the sprite to HelloWorld layer as a child layer.ĬCMenuItemFont::setFontName("Courier New") ĬCLabelBMFont* labelNew = CCLabelBMFont::create("Restart Game!", "bitmapFontTest3.fnt") ĬCMenuItemLabel* itemNew = CCMenuItemLabel::create(labelNew, this, menu_selector(GameOverLayer::menuRestartCallback)) ĬCLabelBMFont* labelQuit = CCLabelBMFont::create("Quit", "bitmapFontTest3.fnt") ĬCMenuItemLabel* itemQuit = CCMenuItemLabel::create(labelQuit, this, menu_selector(GameOverLayer::menuCloseCallback)) ĬCMenu* menu = CCMenu::create( itemNew, itemQuit, NULL) PSprite->setPosition(ccp(size.width/2, size.height/2)) Place the sprite on the center of the screen Add add a splash screen, show the cocos2d splash image.ĬCSprite* pSprite = CCSprite::create("IntroScene.png") Get window size and place the label upper. add the label as a child to this Layer Menu->setPosition(ccp(size.width / 2, size.height / 2)) Menu->alignItemsVerticallyWithPadding(100) ĬCMenuItemSprite* sprite = CCMenuItemSprite::itemFromNormalSprite(question2, question, this, menu_selector(Bug458Layer::selectAnswer)) ĬCLayerColor* layer = CCLayerColor::layerWithColorWidthHeight(ccc4f(0,0,255,255), 100, 100) ĬCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight(ccc4f(255,0,0,255), 100, 100) ĬCMenuItemSprite* sprite2 = CCMenuItemSprite::itemFromNormalSprite(layer, layer2, this, menu_selector(Bug458Layer::selectAnswer)) ĬCMenu* menu = CCMenu::menuWithItems(sprite, sprite2, NULL) QuestionContainerSprite* question2 = new QuestionContainerSprite() QuestionContainerSprite* question = new QuestionContainerSprite() You can rate examples to help us improve the quality of examples.ĬCSize size = CCDirector::sharedDirector()->getWinSize() These are the top rated real world C++ (Cpp) examples of CCMenu::alignItemsVerticallyWithPadding extracted from open source projects. ![]() C++ (Cpp) CCMenu::alignItemsVerticallyWithPadding - 30 examples found. It is a part of the Cocos2d-x game engine. Overall, the `CCMenu alignItemsVerticallyWithPadding` method is a convenient way to arrange menu items in a vertical list with a set padding. The `alignItemsVerticallyWithPadding` method is used to set a padding of 5 pixels between each score item. In this example, we create a menu with menu items generated for each high score in the `highScores` vector. ScoresMenu->alignItemsVerticallyWithPadding(5) The menu items will be arranged vertically in the center of the screen.Īnother example could be creating a list of high scores for a game:Īuto scoreLabel = Label::createWithTTF("High Score: " + score, "fonts/Marker Felt.ttf", 24) Īuto scoreItem = MenuItemLabel::create(scoreLabel) In this example, we create a menu with three items and set the padding between each item to 10 pixels. Menu->alignItemsVerticallyWithPadding(10) // Set padding of 10 ![]() It arranges menu items vertically with a set padding between each item.Īuto menu = Menu::create(item1, item2, item3, nullptr) If( isRetina])padding = (2.The `alignItemsVerticallyWithPadding` method is a part of the `CCMenu` class in the Cocos2d-x game engine. flag stored in app delegate to know whether we are retina I'd hate to do something like this but I will if no better solution exists: float padding = 4.0f Any ideas as to why?Ĭode: CCMenuItemSprite *itemPlay = On non-retina device the padding appears as expected, but when in retina mode on simulator the padding seems to be doubled. I'm using to layout several buttons (CCMenuItemSprite) vertically.
0 Comments
Leave a Reply. |