直接上个例子吧!就是这么直接~~~=……=
  json中的内容:1
2
3
4
5
6
7{
  loadingtips_1:"---tips1---",
  loadingtips_2:"---tips2---",
  loadingtips_3:"---tips3---",
  loadingtips_4:"---tips4---",
  loadingtips_5:"---tips5---"
}
  json文件载入:1
2
3
4
5
6var TransJson = cc.Class.extend({
json_file: null,
ctor:
cc.loader.loadJson("res/local.zh.json");
json_file = data;
})
   json文件读取:1
2
3
4
5
6var readJson = function(key){
    if(TransJson.json_file==null) {
       TODO
    }
    return TransJson.json_file[key];
}
   使用例子(加载界面随机tips):1
2var tips = readJson("loadingtips_" + (Math.floor(Math.random() * 5)).toString());
//Math的使用跟其它引擎基本一致!