"Independent Developer ER cocos2d-x combat 009" COCOS2DX menu item Ccmenu use

Source: Internet
Author: User

The menus in COCOS2DX are implemented with the Ccmenu/menu class, which is a container for loading various menu items, such as images, system fonts, and so on.

The theory is not to say, first on the code:

ccmenuitemtoggle* item1 = Ccmenuitemtoggle::createwithtarget (This,  menu_selector (Helloworld::menuitemtoggle),    ccmenuitemfont::create ("On1"), Ccmenuitemfont::create ("off1"),    Ccmenuitemfont::create ("On2"), Ccmenuitemfont::create ("Off2"),    ccmenuitemfont::create ("On3"), Ccmenuitemfont :: Create ("OFF3"),    ccmenuitemfont::create ("On4"), Ccmenuitemfont::create ("Off4"),    NULL); ccmenuitemimage* item2 = ccmenuitemimage::create ("Closenormal.png", "closeselected.png", this, Menu_selector ( Helloworld::menuitemtoggle)); Cclabelttf *lable = cclabelttf::create ("Cclabelttf", "fonts/arial", 32); Ccmenuitemlabel *item3 = Ccmenuitemlabel::create (lable, this, Menu_selector (Helloworld::menuitemtoggle)); Ccmenu *menu = ccmenu::create (item1, item2, Item3, NULL); menu->alignitemsverticallywithpadding (+); AddChild (menu) ; Menu->setposition (VISIBLESIZE.WIDTH/2-VISIBLESIZE.HEIGHT/2 + 100);
Define the callback function at the same time:
void Helloworld::menuitemtoggle (Ccobject *psender) {cclog ("Helloworld::menuitemtoggle"); return;}

The results are as follows:



Recommended Blog:

"CSB" http://blog.csdn.net/chenqiai0/article/details/46633407

"Frame animation" http://blog.csdn.net/chenqiai0/article/details/46808109

"Making plist" http://blog.csdn.net/chenqiai0/article/details/46820669

"Load Plist" http://blog.csdn.net/chenqiai0/article/details/46820979

"scale9sprite" http://blog.csdn.net/chenqiai0/article/details/46832761


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Independent Developer ER cocos2d-x combat 009" COCOS2DX menu item Ccmenu use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.