mirror of https://github.com/axmolengine/axmol.git
fixed #611: add some functions for lua
This commit is contained in:
parent
29efe9bd39
commit
a3e9679578
|
@ -284,9 +284,18 @@ namespace cocos2d{
|
|||
{}
|
||||
virtual ~CCMenuItemToggle();
|
||||
/** creates a menu item from a list of items with a target/selector */
|
||||
static CCMenuItemToggle* itemWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
|
||||
static CCMenuItemToggle* itemWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
|
||||
/** initializes a menu item from a list of items with a target selector */
|
||||
bool initWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args);
|
||||
|
||||
// The follow methods offered to lua
|
||||
/** creates a menu item with a item */
|
||||
static CCMenuItemToggle* itemWithItem(CCMenuItem *item);
|
||||
/** initializes a menu item with a item */
|
||||
bool initWithItem(CCMenuItem *item);
|
||||
/** add more menu item */
|
||||
void addSubItem(CCMenuItem *item);
|
||||
|
||||
/** return the selected item */
|
||||
CCMenuItem* selectedItem();
|
||||
// super methods
|
||||
|
|
|
@ -649,6 +649,30 @@ namespace cocos2d{
|
|||
this->setSelectedIndex(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
CCMenuItemToggle* CCMenuItemToggle::itemWithItem(CCMenuItem *item)
|
||||
{
|
||||
CCMenuItemToggle *pRet = new CCMenuItemToggle();
|
||||
pRet->initWithItem(item);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
bool CCMenuItemToggle::initWithItem(CCMenuItem *item)
|
||||
{
|
||||
CCMenuItem::initWithTarget(NULL, NULL);
|
||||
this->m_pSubItems = new CCMutableArray<CCMenuItem*>();
|
||||
m_pSubItems->addObject(item);
|
||||
m_uSelectedIndex = UINT_MAX;
|
||||
this->setSelectedIndex(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCMenuItemToggle::addSubItem(CCMenuItem *item)
|
||||
{
|
||||
m_pSubItems->addObject(item);
|
||||
}
|
||||
|
||||
CCMenuItemToggle::~CCMenuItemToggle()
|
||||
{
|
||||
CC_SAFE_RELEASE(m_pSubItems);
|
||||
|
|
|
@ -125,6 +125,10 @@ namespace cocos2d{
|
|||
|
||||
CCMenuItemToggle();
|
||||
|
||||
static CCMenuItemToggle* itemWithItem(CCMenuItem *item);
|
||||
bool initWithItem(CCMenuItem *item);
|
||||
void addSubItem(CCMenuItem *item);
|
||||
|
||||
CCMenuItem* selectedItem();
|
||||
// super methods
|
||||
virtual void activate();
|
||||
|
|
Loading…
Reference in New Issue