CCFileUtils.cpp 里面
我新建了一个lua的工程 参照lua-tests 弄一个简单调用cocostudio 场景
local function main()
collectgarbage(“collect”)
– avoid memory leak
collectgarbage(“setpause”, 100)
collectgarbage(“setstepmul”, 5000)
cc.FileUtils:getInstance():addSearchResolutionsOrder(“src”);
cc.FileUtils:getInstance():addSearchResolutionsOrder(“res”);
cc.FileUtils:getInstance():addSearchResolutionsOrder(“res/LoadSceneEdtiorFileTest”);
local function createStudioScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile(“res/LoadSceneEdtiorFileTest/FishJoy2.json”)
return node
end
– run
local sceneGame = cc.Scene:create()
local root = createStudioScene();
if nil~= root then
sceneGame:addChild(root, 0, 1)
else
print(“root = NULL”)
end
if cc.Director:getInstance():getRunningScene()then
cc.Director:getInstance():replaceScene(sceneGame)
else
cc.Director:getInstance():runWithScene(sceneGame)
end
end
资源目录:LoadSceneEdtiorFileTest是从lua-tests 资源res 拷贝出来的
D:\cocos\MyGame\res\LoadSceneEdtiorFileTest
运行总是找不到图片文件 我把下面的函数改成那样 就可以运行
!DWLCI
std::string FileUtils::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath)
{
std::string file = filename;
std::string file_path = “”;
size_t pos = filename.find_last_of("/");
if (pos != std::string::npos)
{
file_path = filename.substr(0, pos+1);
file = filename.substr(pos+1);
}
// searchPath + file_path + resourceDirectory
std::string path = searchPath;
path += file_path;
path += resolutionDirectory;
path = getFullPathForDirectoryAndFilename(path, file);
//CCLOG("getPathForFilename, fullPath = %s", path.c_str());
return path;
}
这一块是不是有点问题啊?
// searchPath + file_path + resourceDirectory
std::string path = searchPath;
path += file_path;
path += resolutionDirectory;
// searchPath + resourceDirectory + file_path
std::string path = searchPath;
path += resolutionDirectory;
path += file_path;
我想问一下 是不是我资源路径配置错了 还是Cocos2dx3.0 库 存在这个问题?
)