cocos2d-x lua使用协程异步加载的BUG

前端之家收集整理的这篇文章主要介绍了cocos2d-x lua使用协程异步加载的BUG前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

self->addImageAsync(configFilePath,[=](Texture2D* tex){
int ID = (tex) ? (int)tex->_ID : -1;
int* luaID = (tex) ? &tex->_luaID : nullptr;
//toluafix_pushusertype_ccobject(tolua_S,ID,luaID,(void*)tex,"cc.Texture2D");
toluafix_pushusertype_ccobject(LuaEngine::getInstance()->getLuaStack()->getLuaState(),"cc.Texture2D");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler,1);
LuaEngine::getInstance()->removeScriptHandler(handler);
});

把这段代码改一下就对了,放参数的lua_State是coroutine的,调用函数的lua_Statue是主线程的.

原文链接:https://www.f2er.com/cocos2dx/339559.html

猜你在找的Cocos2d-x相关文章