本文整理汇总了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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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
}
示例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
}