第一次写博客,饮水思源,回馈大家。
在手游制作工程中有时候需要知道游戏加载的资源。
针对cocos2d
-
修改cocos2d-x引擎读取资源函数,记录所有操作到log文件中。
步骤如下,在函数:
std::stringCCFileUtils::fullPathForFilename(constchar* pszFileName)
中添加如下代码
if (cacheIter !=m_fullPathCache.end())
{
//CCLOG("Return full path from cache: %s",cacheIter->second.c_str());
return cacheIter->second;
}
//以下红色代码是添加部分
std::stringlowerCase2(pszFileName);
if(std::string::npos != lowerCase2.find(".png")||
std::string::npos != lowerCase2.find(".mp3")||
std::string::npos != lowerCase2.find(".plist")){
SGSLOGW(pszFileName);
CCLOG("---%s", pszFileName);
}
-
游戏运行之后会把使用的全部资源记录到log文件中,编写一个脚本把不在log文件中的资源全部删除。
-
最后查漏补缺