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

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

原文地址:https://www.cnblogs.com/pengkun/p/3791407.html