cocos2d-x + Lua(2) C++和lua数据通讯之间的互调(4)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-10 12:17 点击:次
p> else if(typestr->isEqual(CCString::create("int")))
p> {
p> lua_pushnumber(ls, strnr->intValue());
p> }
p> else if(typestr->isEqual(CCString::create("bool")))
p> {
p> lua_pushboolean(ls, strnr->boolValue());
p> }
p> }
p> }
p> /*
p> lua_call
p> 第一个参数:函数的参数个数
p> 第二个参数:函数返回值个数
p> */
p> lua_call(ls, countnum, 1);
p>
p> const char* iResult = lua_tostring(ls, -1);
p>
p> return iResult;
p>}
p>
p>//带参执行Lua方法无返回值
p>const void PublicSendLuaData::callLuaFuncPar(const char* luaFileName,const char* functionName,CCArray* arraypar,CCArray* arraypartype){
p> lua_State* ls = CCLuaEngine::defaultEngine()->getLuaStack()->getLuaState();
p>
p> int isOpen = luaL_dofile(ls, getFileFullPath(luaFileName));
p> if(isOpen!=0){
p> CCLOG("Open Lua Error: %i", isOpen);
p> }
p>
p> lua_getglobal(ls, functionName);
p> int countnum = arraypar->count();
p> if(countnum>0)
p> {
p> for (int i = 0; i<arraypar->count(); i++) {
p> CCString* typestr = (CCString*)arraypartype->objectAtIndex(i);
p> CCString* strnr = (CCString*)arraypar->objectAtIndex(i);
p> if(typestr->isEqual(CCString::create("string")))
p> {
p> lua_pushstring(ls, strnr->getCString());
p> }
p> else if(typestr->isEqual(CCString::create("int")))
p> {
p> lua_pushnumber(ls, strnr->intValue());
p> }
p> else if(typestr->isEqual(CCString::create("bool")))
p> {
p> lua_pushboolean(ls, strnr->boolValue());
p> }
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>