Quick-cocos2d-x的热更新机制实现(终极版2)(更新3.3版本)

搜索路径问题,还有如果用了ccs 那么你可以看下我之前发的这个帖子或许对你有帮助http://www.cocoachina.com/bbs/read.php?tid-213095.html

1.那appPlatform中调的java的方法getAppBaseResourcePath的实现可以给个例子么,不清楚要怎么写。2.如果只想把apk安装到默认路径下那还需要做getAppBaseResourcePath这个么。3.appdelegate中searchPaths.push_back(sharedFileUtils->getWritablePath() + “upd/”);searchPaths.push_back(strBasePath + “res/”); 中sharedFileUtils->getWritablePath() 与strBasePath 的路径是一样的么

  1. 这个很简单啊 在android 上层一句话就搞定啊,this.getFilesDir().getAbsolutePath() + “/” 其中的this是指当前的Activity。
    2.如果是默认路径可以不需要getAppBaseResourcePath。
    3.不一定是一样的。

我下载了你的sample
然后将launcher.zip加入到res/lib目录下
修改了代码里面的main.lua
local fileUtils = cc.FileUtils:getInstance()
cc.FileUtils:getInstance():setPopupNotify(false)
– 清除fileCached 避免无法加载新的资源。
fileUtils:purgeCachedEntries()
cc.FileUtils:getInstance():addSearchPath(“res/”)
cc.LuaLoadChunksFromZIP(“lib/launcher.zip”)

运行提示下面的错误

load “launcher.config”, error: syntax error during pre-compilation.
load “launcher.init”, error: syntax error during pre-compilation.
load “launcher.launcher”, error: syntax error during pre-compilation

是不是因为launcher.zip是用luajit编译的不支持64位,还是其它原因啊?

launcher.zip 别用我编译的自己编译生成下。

你的zip是用什么编译生成的,是直接用sublime中的quickxdev 还是luacompile?

quick 自带的模块。

你好,我是新手,刚学LUA,有个问题就是搞不清楚,那个launcher/init.lua 没有require(“cocos.init”),怎么能调用cocos里的空间及函数呢例如cc.FileUtils:getInstance():getWritablePath(),c++里一定要调用头文件的,所以不明白

大神,代码里是怎么从APPDELEGATE 到 main 或其他的。。。没看懂啊 呜呜呜

这个Launcher到底是什么,还有, 这个是叫更新脚本器么 。。这个到底用来干嘛的。。为啥每次都会下载它 求解决啊 亲们

下载完launcher后 重新require main的时候没有进去是什么情况 3.3版本

LUA ERROR: :233: bad argument #1 to ‘loadstring’ (string expected, got nil)
function Launcher.doFile(path)
local fileData = cc.HelperFunc:getFileData(path)
local fun = loadstring(fileData)
local ret, flist = pcall(fun)
if ret then
return flist
end

return flist

end

出现上面这个问题是因为在win32里搜索路径不正确,在AppDelegate的AppDelegate::initResourcePath()中searchPaths.push_back(“res/”);和searchPaths.push_back(“src/”);这两句添加了搜索路径以后,跟踪到FileUtils里的fullPathForFilename方法以后,发现搜索路径里的"res/"的完整路径是"工程路径/runtime/res/“而不是"工程路径/res/”,所以找不到flist文件。

解决办法就是在main.lua里的require(“launcher.launcher”)这句之前加上cc.FileUtils:getInstance():addSearchPath(“res/”)

版主请问下,现在我们用的quick 3.3,按照文章中最新给的sample.zip测试,把代码打成game.zip的包,ios没问题,但在安卓上,更新几次,就只会读assets/lib/game.zip,不读upd/lib/game.zip,从Appdelegate就直接加载assets/下了,log如下

01-19 21:28:50.733: D/cocos2d-x debug info(6238): create rendererRecreatedListener for GLProgramState
01-19 21:28:50.743: D/cocos2d-x debug info(6238): c++ writable path:/data/data/com.demo.test/files/upd/
01-19 21:28:50.853: D/cocos2d-x debug info(6238): Quick-Cocos2d-x C++ support ready.
01-19 21:28:50.873: D/CCFileUtils-android.cpp(6238): relative path = res/lib/game.zip
01-19 21:28:50.983: D/cocos2d-x debug info(6238): lua_loadChunksFromZIP() - load zip file: assets/res/lib/game.zip*
01-19 21:28:51.183: D/cocos2d-x debug info(6238): lua_loadChunksFromZIP() - loaded chunks count: 399
01-19 21:28:51.183: D/cocos2d-x debug info(6238): launcher ctor

如果读assets下,都会打出这句话,而且是CCFileUtils-android.cpp打出的
relative path = res/lib/game.zip
还请楼主帮忙看下,感激不尽!

如果我想用quick里的cc.AssetsManagerEx:create来做,该肿么办?