cocos2d-x android环境中lua脚本的io操作

时间:2014-06-18 14:58:32   收藏:0   阅读:294

因为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();

cocos2d-x android环境中lua脚本的io操作,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!