![]() ![]() Remember to declare this function in MainMenu.h This tells the CCMenuItemSprite which function to call when a touch is detected, and should be a function in the class MainMenu of the following structure: void MainMenu::menuStartGameCallback(CCObject* sender) Notes: menu_selector(MainMenu::menuStartGameCallback) create a menu to hold the buttons (remembering to NULL terminate the list)ĬCMenu *menu = CCMenu::create(startGameItem, NULL) create a menu item (button) with the up/down spritesĬCMenuItemSprite* startGameItem = CCMenuItemSprite::create(startGameSprite, startGameSpriteClick, this, menu_selector(MainMenu::menuStartGameCallback)) I would create a menu as follows: // create the sprites for button up and button downĬCSprite* startGameSprite = CCSprite::createWithSpriteFrameName("start_button_up.png") ĬCSprite* startGameSpriteClick = CCSprite::createWithSpriteFrameName("start_button_down.png") Until you add it as as a child node it will not be rendered. ![]() Have you added the menu as a child to your scale/current layer? Would appreciate any assistance! Thanks :) I guess it needs an action to tell it what to do when pressed, I have code that I can put inside that, but I am not sure what I need to put to call the action, ordinarily it would be a void or IBAction but this is Cocos so I am unfamiliar with it. I can create the image.png for it no problem, but if anyone could assist in helping me with what I need to type for the button to appear, for the moment, let's use hard coded values, say for example, to put it in the top left hand corner of the screen if possible? PMenu = CCMenu::create(startGameItem, NULL) Īll I want to do is add another button and call it 'Information' StartGameItem->setPosition( GameController::sharedGameController()->getPositionOfUIItem( "GUI_StartButton-image" ) ) StartGameSpriteClick->setColor( ccc3(128, 128, 128) ) ĬCMenuItemSprite *startGameItem = CCMenuItemSprite::create(startGameSprite, startGameSpriteClick, NULL, this, menu_selector(MainMenu::menuStartGameCallback)) The project is a Cocos2d-x project, and here is the existing start button code fileName = (CCString*)sc->imageDict->objectForKey("GUI_StartButton-image") ĬCSprite *startGameSprite = CCSprite::createWithSpriteFrameName( fileName->m_sString.c_str() ) ĬCSprite *startGameSpriteClick = CCSprite::createWithSpriteFrameName( fileName->m_sString.c_str() ) I am looking to add a button to a menu screen, it does not need to be anything complicated, in fact, the easier the better! iPhone - UIViewController not rotating when device orientation changes.Extending UIScrollView and Monitoring Scroll Events.UITableViewCell Custom accessory - get the row of accessory.Importing OpenSSH RSA Public / Private Key Pair into Apple's Keychain Access.Play video from cache in iphone programmatically.Ionic ion-view header behind ios status bar.Does CLLocationManager work without internet/cellular connection?.How do I apply UIAppearance Proxy properties to UILabel?.initWithFrame : reuseIdentifier : is deprecated. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |