c++调用lua函数2中方式
http://my.oschina.net/kkkkkkkkkkkkk/blog/521496
上一篇 续集
.. 其中handler 通过手动改 tolua 生成的 cpp文件获取 .. void toLuaFunc::callLuaFunc(const char*ARG) { CC_ASSERT(handler > 0, "call lua func 's handle must bigger than 0"); /* 方法1 发送事件到lua cocos2d::CommonScriptData data(handler, ARG); cocos2d::ScriptEvent scriptEvent(cocos2d::kCommonEvent, &data); cocos2d::LuaEngine::getInstance()->sendEvent(&scriptEvent); */ // 方法2 cocos2d::LuaEngine::getInstance()->getLuaStack()->clean(); cocos2d::LuaEngine::getInstance()->getLuaStack()->pushString(ARG); cocos2d::LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); cocos2d::LuaEngine::getInstance()->getLuaStack()->clean(); }