cocos2d-x 2.2.0 控制lua脚本加载时的搜索路径
原文链接:http://segmentfault.com/blog/mituba/1190000000454114
在lua语言中, cocos2d-x重载了原本的lua的require加载方式。(见Cocos2dxLuaLoader.cpp ) 怎么做呢? Cocos2dxLuaLoader内部是使用 以下C++代码实现了在iOS和android平台上,程序先从下载路径下的scripts文件夹寻找lua文件,再从程序内置资源路径下的scripts文件夹寻找lua文件的目标。 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) std::string downloadedScriptPath = CCFileUtils::sharedFileUtils()->getWritablePath() + "scripts"; CCFileUtils::sharedFileUtils()->addSearchPath(downloadedScriptPath.c_str()); std::string scriptPath = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts"); CCFileUtils::sharedFileUtils()->addSearchPath(scriptPath.c_str()); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) std::string downloadedScriptPath = CCFileUtils::sharedFileUtils()->getWritablePath() + "/scripts"; CCFileUtils::sharedFileUtils()->addSearchPath(downloadedScriptPath.c_str()); CCFileUtils::sharedFileUtils()->addSearchPath("assets/scripts"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) //TODO #else _ERROR_ #endif ??
??
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |