fixed #986: Add init() member funciton of CCMenu class.

This commit is contained in:
James Chen 2012-02-29 10:07:18 +08:00
parent f166ee2611
commit 6c01009a18
2 changed files with 49 additions and 39 deletions

View File

@ -72,6 +72,9 @@ 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);

View File

@ -72,7 +72,7 @@ namespace cocos2d{
return menuWithItems(item, NULL);
}
bool CCMenu::initWithItems(CCMenuItem* item, va_list args)
bool CCMenu::init()
{
if (CCLayer::init())
{
@ -99,7 +99,18 @@ namespace cocos2d{
s.height -= r.size.height;
}
setPosition(ccp(s.width/2, s.height/2));
// [self alignItemsVertically];
m_pSelectedItem = NULL;
m_eState = kCCMenuStateWaiting;
return true;
}
return false;
}
bool CCMenu::initWithItems(CCMenuItem* item, va_list args)
{
if (init())
{
int z=0;
if (item)
@ -113,13 +124,9 @@ namespace cocos2d{
i = va_arg(args, CCMenuItem*);
}
}
// [self alignItemsVertically];
m_pSelectedItem = NULL;
m_eState = kCCMenuStateWaiting;
return true;
}
return false;
}