拿到了一套项目代码,lua写的。只有src跟res。
然后想让他在windows上跑起来。我先用命令行new了一个lua的hello world工程,编译通过。
然后把src跟res放进去重新编译,黑屏失败。
是在main.lua里面有一句
–[[
检查基础版本
如果基础版本 > 本地存储的 则删除热更的目录 然后写入 对应的版本号 这里全部用本地的。
否则 不处理
]]
function chkBaseVersion( )
require("lfs")
--删除一个目录
local function _rmDir(path )
--[[
如果目录本身就不存在 则 不处理
]]
if not cc.FileUtils:getInstance():isFileExist(path) then
return
end
local iter, dir_obj = lfs.dir(path)
while true do
local dir = iter(dir_obj)
if dir == nil then break end
if dir ~= "." and dir ~= ".." then
local curDir = path.."/"..dir
--print(curDir)
local mode = lfs.attributes(curDir, "mode")
if mode == "directory" then
_rmDir(curDir)
elseif mode == "file" then
os.remove(curDir)
end
end
end
lfs.rmdir(path)
end
--[[
读取本地的baseVersion
]]
local readBaseVersion = function ( )
local baseVersionPath = cc.FileUtils:getInstance():getWritablePath() .. "baseversion.txt"
local ofile = io.open(baseVersionPath,"rb")
local version = 100
if ofile then
local sContent = ofile:read("*a")
if sContent and string.len(sContent)>0 then
version = tonumber(sContent)
end
ofile:close()
else
end
return version
end
--[[
将新的baseVersion 写入 本地
]]
local writeBaseVersion = function ( version )
local baseVersionPath = cc.FileUtils:getInstance():getWritablePath() .. "baseversion.txt"
local oFile = io.open( baseVersionPath,"w" )
oFile:write(version)
oFile:close()
end
--[[
获取包的baseVersion
]]
local curBaseVersion = GAME_BASE_VERSION
local storeageBaseVersion = readBaseVersion()
local path = cc.FileUtils:getInstance():getWritablePath() .. "new/"
--print(path)
if storeageBaseVersion == nil then
storeageBaseVersion = 100
end
if curBaseVersion > storeageBaseVersion then
echo("当前版本大于热更版本,删除热更目录")
_rmDir(path)
--如果删除了 缓存 则需要重写写入 版本号
writeBaseVersion(curBaseVersion)
end
end
