Пример #1
0
void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)
{
    if (methodName == NULL)
        return;
    
    const char *methodNameStr = json_string_value(methodName);
    
    for (unsigned int i = 0; i < NDKHelper::selectorList.size(); ++i)
    {
        if (NDKHelper::selectorList[i].getName().compare(methodNameStr) == 0)
        {
            CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
            
            if (dataToPass != NULL)
                dataToPass->retain();
            
            SEL_CallFuncND sel = NDKHelper::selectorList[i].getSelector();
            CCNode *target = NDKHelper::selectorList[i].getTarget();
            
            CCFiniteTimeAction* action = CCSequence::create(CCCallFuncND::create(target, sel, (void*)dataToPass), NULL);
            
            target->runAction(action);
            
            if (dataToPass != NULL)
                dataToPass->autorelease();
            break;
        }
    }
}
Пример #2
0
void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)
{
    if (methodName == NULL)
        return;
    
    const char *methodNameStr = json_string_value(methodName);
    
    for (unsigned int i = 0; i < selectorList.size(); ++i)
    {
        if (selectorList[i].getName().compare(methodNameStr) == 0)
        {
            CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
            
            if (dataToPass != NULL)
                dataToPass->retain();
            
            SEL_CallFuncO sel = selectorList[i].getSelector();
            CCObject *target = selectorList[i].getTarget();
            
			callfuncs->addObject(CCCallFuncO::create(target, sel, dataToPass));
			CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(NDKHelper::ExecuteCallfuncs), this, 0, 0, 0, false);
            
            if (dataToPass != NULL)
                dataToPass->autorelease();
            break;
        }
    }
}
Пример #3
0
void CCNotificationHandler::postNotificationOnMainThread(const char *name, CCObject *object)
{
	CCObject *target = new CCNotificationHandler(name, object);
	target->retain();
	target->autorelease();

	CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCNotificationHandler::postNotification), target, 0, 0, 0, false);
}