local targetPlatform = cc.Application:getInstance():getTargetPlatform() local writablePath = cc.FileUtils:getInstance():getWritablePath() function loadFile(filename) print("loadFile() "..filename) return cc.FileSystem:getStringFromFile(filename) end function loadFileEncode(filename) print("loadFileEncode() "..filename) local fileString = loadFile(filename) if fileString == nil then return nil end local decodeString = cc.FilePackage:decrypt(fileString) return decodeString end function loadRomSettingScript() print("loadRomSettingScript()") local romSettingFile = "romFiles/RomSetting.lua" local romSettingString = nil if targetPlatform == 3 then romSettingString = loadFileEncode(romSettingFile) else romSettingString = loadFile(romSettingFile) end if not romSettingString then return end local luaFunc = loadstring(romSettingString); local romSetting = luaFunc(); if not romSetting then return end local platform = romSetting.Platform local PlatformConfig = require("preload.PlatformConfig"); if PlatformConfig[platform] then local setting if romSetting.isDevMode then setting = PlatformConfig[platform].debug else setting = PlatformConfig[platform].release end for k,v in pairs(setting) do romSetting[k] = v; end end return romSetting; end local function updateSearchPaths() print("updateSearchPaths()") -- RomSetting 其他平台的对应的配置会在打包的时候覆盖core里面的 然后通过此文件加载对应平台的路径 -- paths 默认只有三个目录 local paths = cc.FileUtils:getInstance():getSearchPaths() local pathNums = #paths if pathNums>=1 and pathNums <= 5 then local RomSetting = loadRomSettingScript() local path = paths[1]; -- "assets" table.insert(paths,1,writablePath..RomSetting.Platform.."/") table.insert(paths,2,path..RomSetting.Platform.."/") table.insert(paths,3,writablePath.."games".."/") table.insert(paths,4,path.."games".."/") table.insert(paths,5,writablePath.."core".."/") table.insert(paths,6,path.."core".."/") table.insert(paths,7,writablePath) for k,v in pairs(paths) do print(k..":"..v) end cc.FileUtils:getInstance():setSearchPaths(paths) end end updateSearchPaths(); require("preload.Plugin") require("preload.PluginDevice") require("preload.PluginBugly") require("preload.PluginUmeng") require("preload.PluginHttpDns") initPluginBugly(); initPluginHttpDns(); umengInit();