1.在cocos2d-x-js 3.0中可以使用localstorage 存储keyvalue信息
var Util = cc.Class.extend({
saveData:function(key, value) {
cc.sys.localStorage.setItem(key, value);
},
getData:function(key,defaultValue) {
if(!cc.sys.localStorage.getItem(key)) {
if(defaultValue) {
return defaultValue;
}
return -1;
}
return cc.sys.localStorage.getItem(key);
}
});
Util.getInstance = function () {
if (!this._sharedGame) {
this._sharedGame = new Util();
if (this._sharedGame) {
return this._sharedGame;
}
} else {
return this._sharedGame;
}
return null;
};
Util._sharedGame = null;
2. 可以用来存储用户配置信息,取代c++版本的默认xml读取配置信息