我的办法
在更新资源时在Documents目录下(android是 data/data/…/files/)动态创建文件夹,如下
self.path = device.writablePath
self:createDownPath(self.path …“res/”)
self:createDownPath(self.path…“scripts/”)
–创建文件夹
function UpdateScene:createDownPath( path )
if not self:checkDirOK(path) then
print(“更新目录创建失败,直接开始游戏”)
self:noUpdateStart()
return
else
print(“更新目录存在或创建成功”)
end
end
function UpdateScene:checkDirOK( path )
require “lfs”
local oldpath = lfs.currentdir()
if lfs.chdir(path) then
lfs.chdir(oldpath)
return true
end
if lfs.mkdir(path) then
return true
end
end
注:参考帖子 http://cn.cocos2d-x.org/tutorial/show?id=1017
然后在Main.lua 中,写入如下代码调用更新资源
local writablePath = CCFileUtils:sharedFileUtils():getWritablePath()
CCFileUtils:sharedFileUtils():addSearchPath(writablePath … “res/”)
CCFileUtils:sharedFileUtils():addSearchPath(writablePath … “scripts/”)
CCFileUtils:sharedFileUtils():addSearchPath(“res/”)
CCFileUtils:sharedFileUtils():addSearchPath(“scripts/”)
CCLuaLoadChunksFromZIP(“framework_precompiled.zip”)
require(“app.MyApp”).new():run()
请教下我这样逻辑是对的嘛? 测试是可以更新的 以及 加载更新的资源,感觉有两处代码文件(Resources目录下一处代码,Documents目录动态更新的一处代码),我就是是先加载更新的资源
(之前在社区里看到一篇帖子【热更新 终结版】,对于我们这些初学者来说超级复杂)
非常感谢 阳光七月 帮助