码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-06-18 14:58:32      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:android   http   com   get   使用   文件   

因为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

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

标签:android   http   com   get   使用   文件   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!