Пример #1
0
MenuItemToggle* MenuItemToggle::create(MenuItem *item)
{
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->initWithItem(item);
    ret->autorelease();
    return ret;
}
Пример #2
0
MenuItemToggle * MenuItemToggle::create()
{
    MenuItemToggle *ret = new MenuItemToggle();
    ret->initWithItem(nullptr);
    ret->autorelease();
    return ret;
}
Пример #3
0
MenuItemToggle* MenuItemToggle::create(MenuItem *item)
{
    MenuItemToggle *pRet = new MenuItemToggle();
    pRet->initWithItem(item);
    pRet->autorelease();
    return pRet;
}
Пример #4
0
MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...)
{
    va_list args;
    va_start(args, item);
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->initWithCallback(callback, item, args);
    ret->autorelease();
    va_end(args);
    return ret;
}
Пример #5
0
// XXX: deprecated
MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, ...)
{
    va_list args;
    va_start(args, item);
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->initWithTarget(target, selector, item, args);
    ret->autorelease();
    va_end(args);
    return ret;
}
Пример #6
0
// XXX: deprecated
MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)
{
    va_list args;
    va_start(args, item);
    MenuItemToggle *pRet = new MenuItemToggle();
    pRet->initWithTarget(target, selector, item, args);
    pRet->autorelease();
    va_end(args);
    return pRet;
}
Пример #7
0
MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, const Vector<MenuItem*>& menuItems)
{
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->MenuItem::initWithCallback(callback);
    ret->autorelease();
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
    if (sEngine)
    {
        for (const auto &item : menuItems)
        {
            if (item)
            {
                sEngine->retainScriptObject(ret, item);
            }
        }
    }
#endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    ret->_subItems = menuItems;
    ret->_selectedIndex = UINT_MAX;
    ret->setSelectedIndex(0);
    return ret;
}
Пример #8
0
// FIXME:: deprecated
MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler selector, const Vector<MenuItem*>& menuItems)
{
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->MenuItem::initWithCallback(std::bind(selector, target, std::placeholders::_1));
    ret->autorelease();
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
    if (sEngine)
    {
        for (const auto &item : menuItems)
        {
            if (item)
            {
                sEngine->retainScriptObject(ret, item);
            }
        }
    }
#endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    ret->_subItems = menuItems;
    ret->_selectedIndex = UINT_MAX;
    ret->setSelectedIndex(0);
    return ret;
}