当前位置: 首页>>代码示例>>C++>>正文


C++ CCLuaStack::executeFunctionByHandler方法代码示例

本文整理汇总了C++中CCLuaStack::executeFunctionByHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaStack::executeFunctionByHandler方法的具体用法?C++ CCLuaStack::executeFunctionByHandler怎么用?C++ CCLuaStack::executeFunctionByHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLuaStack的用法示例。


在下文中一共展示了CCLuaStack::executeFunctionByHandler方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SendBinaryMessageToLua

static int SendBinaryMessageToLua(int nHandler,const unsigned char* pTable,int nLength)
{
    if (NULL == pTable || nHandler <= 0) {
        return 0;
    }
    
    if (NULL == CCScriptEngineManager::sharedManager()->getScriptEngine()) {
        return 0;
    }
    
    CCLuaStack *pStack = CCLuaEngine::defaultEngine()->getLuaStack();
    if (NULL == pStack) {
        return 0;
    }

    lua_State *tolua_s = pStack->getLuaState();
    if (NULL == tolua_s) {
        return 0;
    }
    
    int nRet = 0;
    CCLuaValueArray array;
    for (int i = 0 ; i < nLength; i++) {
        CCLuaValue value = CCLuaValue::intValue(pTable[i]);
        array.push_back(value);
    }
    
    pStack->pushCCLuaValueArray(array);
    nRet = pStack->executeFunctionByHandler(nHandler, 1);
    pStack->clean();
    return nRet;
}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:32,代码来源:Lua_web_socket.cpp

示例2: addArmatureFileInfoAsyncCallback

void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent)
{
    if (0 != m_lHandler)
    {
        CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
        CCLuaStack* pStack = pEngine->getLuaStack();
        
        pStack->pushFloat(percent);
        pStack->executeFunctionByHandler(m_lHandler, 1);
        pStack->clean();
    }
}
开发者ID:237676098,项目名称:quick-cocos2d-x,代码行数:12,代码来源:lua_cocos2dx_cocostudio_manual.cpp

示例3: eventCallbackFunc

void LuaCocoStudioEventListener::eventCallbackFunc(CCObject* sender,int eventType)
{
    if (0 != m_lHandler)
    {
        CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
        CCLuaStack* pStack = pEngine->getLuaStack();
        pStack->pushCCObject(sender, "CCObject");
        pStack->pushInt(eventType);
        pStack->executeFunctionByHandler(m_lHandler, 2);
        pStack->clean();
    }
}
开发者ID:fordream,项目名称:quick,代码行数:12,代码来源:lua_cocos2dx_cocostudio_manual.cpp

示例4: movementEventCallback

void LuaArmatureWrapper::movementEventCallback(CCArmature* armature, MovementEventType type,const char* movementID)
{
    if (0 != m_lHandler)
    {
        CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
        CCLuaStack* pStack = pEngine->getLuaStack();
        
        pStack->pushCCObject(armature, "CCArmature");
        pStack->pushInt(type);
        pStack->pushString(movementID);
        pStack->executeFunctionByHandler(m_lHandler, 3);
        pStack->clean();
    }
}
开发者ID:237676098,项目名称:quick-cocos2d-x,代码行数:14,代码来源:lua_cocos2dx_cocostudio_manual.cpp

示例5: frameEventCallback

void LuaArmatureWrapper::frameEventCallback(CCBone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex)
{
    if (0 != m_lHandler)
    {
        CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
        CCLuaStack* pStack = pEngine->getLuaStack();
        
        pStack->pushCCObject(bone, "CCBone");
        pStack->pushString(frameEventName);
        pStack->pushInt(orginFrameIndex);
        pStack->pushInt(currentFrameIndex);
        pStack->executeFunctionByHandler(m_lHandler, 4);
        pStack->clean();
    }
}
开发者ID:237676098,项目名称:quick-cocos2d-x,代码行数:15,代码来源:lua_cocos2dx_cocostudio_manual.cpp

示例6: title

void CCNativeWin32::showAlertViewWithLuaListener(LUA_FUNCTION listener)
{
    /*
    wstring title(m_alertViewTitle.begin(), m_alertViewTitle.end());
    wstring message(m_alertViewMessage.begin(), m_alertViewMessage.end());
    int button = MessageBox(NULL, message.c_str(), title.c_str(), MB_OKCANCEL);
    */
    WCHAR *wszTitleBuf;
    WCHAR *wszMessageBuf;

    int titleBufLen = MultiByteToWideChar(CP_UTF8, 0, m_alertViewTitle.c_str(), -1, NULL, 0);
    int messageBufLen = MultiByteToWideChar(CP_UTF8, 0, m_alertViewMessage.c_str(), -1, NULL, 0);

    wszTitleBuf = new WCHAR[titleBufLen+1];
    wszMessageBuf = new WCHAR[messageBufLen+1];

    memset(wszTitleBuf, 0, sizeof(WCHAR)*(titleBufLen + 1) );

    memset(wszMessageBuf, 0, sizeof(WCHAR)*(messageBufLen + 1) );
    MultiByteToWideChar(CP_UTF8, 0, m_alertViewTitle.c_str(), -1, wszTitleBuf, titleBufLen);
    MultiByteToWideChar(CP_UTF8, 0, m_alertViewMessage.c_str(),-1, wszMessageBuf, messageBufLen);

    int button = MessageBox(NULL,wszMessageBuf, wszTitleBuf, MB_OKCANCEL);

    delete [] wszTitleBuf;
    delete [] wszMessageBuf;

    CCLuaValueDict event;
    event["action"] = CCLuaValue::stringValue("clicked");
    if (button == IDOK || button == IDYES)
    {
        event["buttonIndex"] = CCLuaValue::intValue(1);
    }
    else
    {
        event["buttonIndex"] = CCLuaValue::intValue(2);
    }

    CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
    stack->pushCCLuaValueDict(event);
    stack->executeFunctionByHandler(listener, 1);
}
开发者ID:fordream,项目名称:quick,代码行数:42,代码来源:CCNativeWin32.cpp

示例7: executeTouchCancelledAfterLongClickHandler

void CWidgetLayout::executeTouchCancelledAfterLongClickHandler(CCObject* pSender, CCTouch *pTouch, float fDuration)
{
    if( m_pTouchCancelledAfterLongClickListener && m_pTouchCancelledAfterLongClickHandler )
    {
		(m_pTouchCancelledAfterLongClickListener->*m_pTouchCancelledAfterLongClickHandler)(pSender, pTouch, fDuration);
    }
#if USING_LUA
	else if( m_pTouchCancelledAfterLongClickScriptHandler != 0 )
	{
		CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
		CCLuaStack* pStack = pEngine->getLuaStack();

		pStack->pushCCObject(pSender, "CCObject");
		pStack->pushCCObject(pTouch, "CCTouch");
		pStack->pushFloat(fDuration);

		int nRet = pStack->executeFunctionByHandler(m_pTouchCancelledAfterLongClickScriptHandler, 3);
		pStack->clean();
	}
#endif
}
开发者ID:54993306,项目名称:Classes,代码行数:21,代码来源:WidgetLayout.cpp

示例8: update

void CCHTTPRequest::update(float dt)
{
    if (m_state == kCCHTTPRequestStateInProgress)
    {
#if CC_LUA_ENGINE_ENABLED > 0
        if (m_listener)
        {
            CCLuaValueDict dict;

            dict["name"] = CCLuaValue::stringValue("inprogress");
            dict["dltotal"] = CCLuaValue::floatValue((float)m_dltotal);
            dict["dlnow"] = CCLuaValue::floatValue((float)m_dlnow);
            dict["ultotal"] = CCLuaValue::floatValue((float)m_ultotal);
            dict["ulnow"] = CCLuaValue::floatValue((float)m_ulnow);
            dict["request"] = CCLuaValue::ccobjectValue(this, "CCHTTPRequest");
            CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
            stack->clean();
            stack->pushCCLuaValueDict(dict);
            stack->executeFunctionByHandler(m_listener, 1);
        }
#endif
        return;
    }
    CCDirector::sharedDirector()->getScheduler()->unscheduleAllForTarget(this);
    if (m_curlState != kCCHTTPRequestCURLStateIdle)
    {
        CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCHTTPRequest::checkCURLState), this, 0, false);
    }

    if (m_state == kCCHTTPRequestStateCompleted)
    {
        CCLOG("CCHTTPRequest[0x%04x] - request completed", m_id);
        if (m_delegate) m_delegate->requestFinished(this);
    }
    else
    {
        CCLOG("CCHTTPRequest[0x%04x] - request failed", m_id);
        if (m_delegate) m_delegate->requestFailed(this);
    }

#if CC_LUA_ENGINE_ENABLED > 0
    if (m_listener)
    {
        CCLuaValueDict dict;

        switch (m_state)
        {
            case kCCHTTPRequestStateCompleted:
                dict["name"] = CCLuaValue::stringValue("completed");
                break;

            case kCCHTTPRequestStateCancelled:
                dict["name"] = CCLuaValue::stringValue("cancelled");
                break;

            case kCCHTTPRequestStateFailed:
                dict["name"] = CCLuaValue::stringValue("failed");
                break;

            default:
                dict["name"] = CCLuaValue::stringValue("unknown");
        }
        dict["request"] = CCLuaValue::ccobjectValue(this, "CCHTTPRequest");
        CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
        stack->clean();
        stack->pushCCLuaValueDict(dict);
        stack->executeFunctionByHandler(m_listener, 1);
    }
#endif
}
开发者ID:yinjimmy,项目名称:qmm,代码行数:70,代码来源:CCHTTPRequest.cpp


注:本文中的CCLuaStack::executeFunctionByHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。