mirror of https://github.com/axmolengine/axmol.git
add CCMenu::init() and CCMenu::menu() to create empty menus
This commit is contained in:
parent
c5f7036f7b
commit
4510101e96
|
@ -55,6 +55,10 @@ namespace cocos2d{
|
|||
, m_pSelectedItem(NULL)
|
||||
{}
|
||||
virtual ~CCMenu(){}
|
||||
|
||||
/** creates an empty CCMenu */
|
||||
static CCMenu* menu();
|
||||
|
||||
/** creates a CCMenu with it's items */
|
||||
static CCMenu* menuWithItems(CCMenuItem* item, ...);
|
||||
|
||||
|
@ -64,6 +68,8 @@ namespace cocos2d{
|
|||
*/
|
||||
static CCMenu*menuWithItem(CCMenuItem* item);
|
||||
|
||||
/** initializes an empty CCMenu */
|
||||
bool init();
|
||||
/** initializes a CCMenu with it's items */
|
||||
bool initWithItems(CCMenuItem* item, va_list args);
|
||||
|
||||
|
|
|
@ -44,6 +44,18 @@ namespace cocos2d{
|
|||
//
|
||||
//CCMenu
|
||||
//
|
||||
|
||||
CCMenu* CCMenu::menu()
|
||||
{
|
||||
CCMenu *menu = new CCMenu();
|
||||
if (menu && menu->init()) {
|
||||
menu->autorelease();
|
||||
return menu;
|
||||
}
|
||||
CC_SAFE_DELETE(menu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
@ -65,6 +77,12 @@ namespace cocos2d{
|
|||
return menuWithItems(item, NULL);
|
||||
}
|
||||
|
||||
bool CCMenu::init()
|
||||
{
|
||||
va_list args;
|
||||
return initWithItems(0, args);
|
||||
}
|
||||
|
||||
bool CCMenu::initWithItems(CCMenuItem* item, va_list args)
|
||||
{
|
||||
if (CCLayer::init())
|
||||
|
|
Loading…
Reference in New Issue