因为android的安装包安装之后,是以压缩文件的形式存储。故在lua脚本中,直接使用io操作(如:io.open等)是无法找到文件的(ios和windows平台无此问题)。

在论坛中找到一个解决办法http://www.cocoachina.com/bbs/read.php?tid=198542

原理是在lua中调用CCString:createWithContentsOfFile方法,使用c++代码去打开文件。具体代码:

local str = CCString:createWithContentsOfFile(CCFileUtils:sharedFileUtils():fullPathForFilename("config/config_skill.json")):getCString();

posted on 2014-06-16 17:52  pengkun  阅读(533)  评论(0编辑  收藏  举报