sa 5 лет назад
Родитель
Сommit
2009c4792d

+ 11 - 15
assets/Script/Game/GameSence.js

@@ -1,5 +1,5 @@
 var cfg = require("Configure")
-var WxCommon = require("../WxCommon")
+var QQCommon = require("../QQCommon")
 
 cc.Class({
     extends: cc.Component,
@@ -712,7 +712,7 @@ cc.Class({
             imgurlData: UserInfo.shareUrl,
             queryData: 'pp=pp'
         }
-        WxCommon.ShareAppMessage(data, this, null);
+        QQCommon.ShareAppMessage(data, null);
     },
 
     onShareBtn: function () {
@@ -723,19 +723,15 @@ cc.Class({
                 imgurlData: UserInfo.shareUrl,
                 queryData: 'pp=pp'
             }
-            this.shareFlag = 1;
-            WxCommon.ShareAppMessage(data, this.node.getComponent("GameSence"), this.node.getComponent("GameSence").comeBack);
-            wx.onShow(res => {
-                if (this.shareFlag == 1) {
-                    var gameOverNode = this.node.getChildByName("GameOver");
-                    var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
-                    countDownLabel.stopAllActions();
-                    this.continueGame();
-
-                    cc.audioEngine.playMusic(this.gamebgMusic, true);
-                    this.shareFlag = 0;
-                }
-            })
+            
+            QQCommon.ShareAppMessage(data, () => {
+				var gameOverNode = this.node.getChildByName("GameOver");
+				var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
+				countDownLabel.stopAllActions();
+				this.continueGame();
+
+				cc.audioEngine.playMusic(this.gamebgMusic, true);
+			});
         } else {
             var gameOverNode = this.node.getChildByName("GameOver");
             var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");

+ 20 - 88
assets/Script/Home/HomeSence.js

@@ -1,13 +1,7 @@
 var WxCommon = require("../WxCommon")
+var QQCommon = require("../QQCommon")
 var cfg = require("Configure")
 
-// @TODO 引入sdk代码
-// import DwSdk from "../duowansdk/DwSdk";
-const debug = false;
-// const objSdk = new DwSdk("布丁弹一弹", debug);
-// 注册sdk的update事件
-// cc.director.on(cc.Director.EVENT_AFTER_DRAW, objSdk.update);
-
 cc.Class({
     extends: cc.Component,
 
@@ -54,78 +48,12 @@ cc.Class({
             this.WxLogin();
             this.initShare();
             // wx.setPreferredFramesPerSecond(30);
-        }
-
-        this.listenGame();
-
-        //SDK接入
-        // if (CC_WECHATGAME) {
-        //     objSdk.showAdIcon(-360, -240, this.node);
-        //     objSdk.showHomeAd();
-        //     var launchOptions = wx.getLaunchOptionsSync();
-        //     console.log(launchOptions.scene);
-        //     let { screenWidth, screenHeight } = wx.getSystemInfoSync();
-
-        //     let style = {
-        //         left: 60,
-        //         top: screenHeight - 100,
-        //         width: screenWidth - 120,
-        //         height: 100
-        //     }
-        //     if (screenWidth <= 360) {
-        //         style.left = (screenWidth - 320) / 2;
-        //     }
-        //     let indexBannerId = 'adunit-de205564802e4627',
-        //         deadBannerId = 'adunit-7a574e7546c7062d',
-        //         accountBannerId = 'adunit-1e3576e27d61175a';
-
-        //     window.indexBanner = wx.createBannerAd({
-        //         adUnitId: indexBannerId,
-        //         style: style
-        //     })
-
-        //     indexBanner.onError(err => {
-        //         console.log('indexBanner 拉取失败', err)
-        //     })
-
-        //     indexBanner.onResize(res => {
-        //         console.log(res.width, res.height)
-        //         indexBanner.style.left = (screenWidth - res.width) / 2;
-        //         indexBanner.style.top = screenHeight - res.height;
-        //     })
-
-        //     indexBanner.onLoad(() => {
-        //         indexBanner.show()
-        //     })
-
-        //     window.deadBanner = wx.createBannerAd({
-        //         adUnitId: deadBannerId,
-        //         style: style
-        //     })
-
-        //     deadBanner.onResize(res => {
-        //         deadBanner.style.left = (screenWidth - res.width) / 2;
-        //         deadBanner.style.top = screenHeight - res.height;
-        //     })
-
-        //     deadBanner.onError(err => {
-        //         console.log('deadBanner 拉取失败', err)
-        //     })
-
-        //     window.accountBanner = wx.createBannerAd({
-        //         adUnitId: accountBannerId,
-        //         style: style
-        //     })
-
-        //     accountBanner.onResize(res => {
-        //         accountBanner.style.left = (screenWidth - res.width) / 2;
-        //         accountBanner.style.top = screenHeight - res.height;
-        //     })
-
-        //     accountBanner.onError(err => {
-        //         console.log('accountBanner 拉取失败', err)
-        //     })
-        // }
+			this.listenGame();
+		}
+		
+		if (CC_QQPLAY) {
+			// this.QQLogin();
+		}
     },
 
     start() {
@@ -138,6 +66,12 @@ cc.Class({
         this.friendContentNode = this.rankNode.getChildByName('FriendContent')
     },
 
+	QQLogin() {
+		if(GameStatusInfo && GameStatusInfo.openId) {
+			BK.Console.log('登录成功')
+		}
+	},
+
     WxLogin() {
         if (UserInfo.platform != 1) {
             return;
@@ -177,15 +111,13 @@ cc.Class({
     },
 
     listenGame() {
-        if (CC_WECHATGAME) {
-            // var date = UserInfo.GetNowFormatDate();
-            this.OnUpdateGame();
-            WxCommon.SetEnableDebug(false);
-            WxCommon.OnShow(null, this, null);
-            WxCommon.ShowShareMenu();
-            WxCommon.OnShareAppMessage(null, this, this.shareCallback);
-            WxCommon.GetSystemInfo(null, this, null);
-        }
+		// var date = UserInfo.GetNowFormatDate();
+		this.OnUpdateGame();
+		WxCommon.SetEnableDebug(false);
+		WxCommon.OnShow(null, this, null);
+		WxCommon.ShowShareMenu();
+		WxCommon.OnShareAppMessage(null, this, this.shareCallback);
+		WxCommon.GetSystemInfo(null, this, null);
     },
 
     OnUpdateGame() {

+ 39 - 0
assets/Script/QQCommon.js

@@ -0,0 +1,39 @@
+class QQCommon {
+	constructor () {
+
+	}
+
+	static getInstance() {
+        if (!QQCommon.instance && CC_WECHATGAME) {
+            QQCommon.instance = new QQCommon();
+        }
+        return QQCommon.instance;
+	}
+	
+	ShareAppMessage(data, callback) {
+		BK.Share.share({
+			qqImgUrl: data.imgurlData,
+			summary: data.title,
+			isToFriend: true,
+			extendInfo: data.extendInfo || '',
+			success: function(res) {
+				BK.Console.log('分享成功', res.code, JSON.stringify(res.data));
+
+				if(res.data.ret == 0) {
+					callback && callback(res.data)
+				}
+			},
+			fail: function(res) {
+				BK.Console.log('分享失败', res.code, JSON.stringify(res.msg));
+			},
+			complete: function(res) {
+				BK.Console.log('分享完成,不论成功失败');
+			}
+		})
+	}
+
+	GetSystemInfo() {
+		var systemInfo = BK.getSystemInfoSync();
+		return systemInfo;
+	}
+}

+ 1 - 1
assets/Script/Sdk/sdk.js.meta → assets/Script/QQCommon.js.meta

@@ -1,6 +1,6 @@
 {
   "ver": "1.0.5",
-  "uuid": "612373b9-76fa-4c37-ac13-1d23e79b11ba",
+  "uuid": "6675eabe-5a94-4051-9436-4c22f5632db8",
   "isPlugin": false,
   "loadPluginInWeb": true,
   "loadPluginInNative": true,

+ 0 - 5
assets/Script/Sdk.meta

@@ -1,5 +0,0 @@
-{
-  "ver": "1.0.1",
-  "uuid": "bce4d1c8-6144-4f79-b784-7fa6848c489e",
-  "subMetas": {}
-}

+ 0 - 140
assets/Script/Sdk/sdk.js

@@ -1,140 +0,0 @@
-export default class boxSdk {
-    constructor(name) {
-      this.name = name,                               //本游戏名字
-      this.api = 'https://xyxbox.duowan.com/'         //接口域名
-      this.dataList = [],                             //数据列表 存放图标游戏图组合列表
-      this.currentGroup = {}                          //当前选中图标游戏组合
-    }
-  
-    showAdIcon(x, y, node) {
-      let self = this
-      
-      wx.request({
-        url: `${self.api}hz/showAd`,  
-        data: {name:self.name},
-        success: function ({ data }) {
-          let meta = data.data
-          for(let i = 0 ; i < meta.length; i++) {
-            meta[i].small_icon = meta[i].small_icon.replace(/http\:\/\//,'https://')
-          }
-  
-          self.dataList = meta
-  
-          self.renderIcon(x,y,node)
-  
-  
-        }
-      })
-  
-  
-    }
-  
-    renderIcon(x,y,parent) {
-      let self = this
-      let index = (new Date()).getTime() % self.dataList.length
-      self.currentGroup = self.dataList[index]
-      let iconNode = parent.getChildByName("adIcon");
-      if(iconNode) {
-        iconNode.destroy();
-      }
-      wx.downloadFile({
-        url: self.currentGroup.small_icon,
-        header: {},
-        filePath: '',
-        success: function (ret) {
-          var frame = new cc.SpriteFrame(ret.tempFilePath);
-          var node = new cc.Node('adIcon');
-          var sp = node.addComponent(cc.Sprite);
-  
-          var btn = node.addComponent(cc.Button)
-          
-          
-  
-  
-          sp.spriteFrame = frame
-          node.parent = parent;
-          node.x = x 
-          node.y = y 
-          // var widget = node.addComponent(cc.Widget)
-          // console.log(widget)
-          // widget.isAlignTop = true
-          // widget.isAlignLeft = true
-          // widget.left = x
-          // widget.top = y 
-          btn.node.on(cc.Node.EventType.TOUCH_START, function () {
-            wx.request({
-              url: `${self.api}hz/static?field=img`,
-              data: { name: self.currentGroup.name },
-              success: () => { }
-            })
-  
-            if(self.currentGroup.app_id) {
-              wx.navigateToMiniProgram({
-                appId: self.currentGroup.app_id,
-                path: self.currentGroup.path,
-                extraData: {},
-                success(){console.log('跳转成功')}
-              })
-            }else {
-              wx.previewImage({
-                urls: [self.currentGroup.big_image]
-              })
-            }
-            
-  
-            
-            self.renderIcon(x,y,parent)
-          })
-  
-          
-  
-  
-        }
-      })
-  
-  
-  
-    }
-  
-    openQrcode() {
-      let self = this
-      wx.request({
-        url: `${self.api}hz/common`,
-        data: {},
-        success: ({ data }) => {
-          wx.previewImage({
-            urls: [data.data.gzh_qr_code]
-          })
-        }
-      })
-  
-    }
-  
-  
-    oepnGameCenter() {
-      wx.request({
-        url: `${self.api}hz/common`,
-        data: {},
-        success: ({ data }) => {
-          wx.previewImage({
-            urls: [data.data.hz_picture]
-          })
-        }
-      })
-    }
-  
-    initSdk(sceneId, path) {
-      let gameName = this.name
-      if (sceneId == 1012) {
-        wx.request({
-          url: `${self.api}hz/static?field=qr`,
-          data: { name: gameName },
-          success: () => { },
-  
-        })
-      }
-    }
-  
-  
-  
-  }

+ 4 - 0
build-templates/qqplay/gameConfig.json

@@ -0,0 +1,4 @@
+{
+  "viewMode":1,
+  "enterUrl":""
+}

+ 433 - 0
build-templates/qqplay/libs/qqplay-adapter.js

@@ -0,0 +1,433 @@
+// BK.Script.loadlib('GameRes://libs/qqPlayCore.js');
+
+var gl;
+var window = this;
+window.addEventListener = function () {};
+window.removeEventListener = function () {};
+
+var navigator = window.navigator = {
+    userAgent: 'qqplay ' + GameStatusInfo.platform + ' QQ/' + GameStatusInfo.QQVer,
+    appVersion: ''
+};
+
+BK.Script.loadlib('GameRes://libs/xmldom/dom-parser.js');
+
+// import element node
+BK.Script.loadlib('GameRes://libs/element/utils.js');
+BK.Script.loadlib('GameRes://libs/element/base.js');
+BK.Script.loadlib('GameRes://libs/element/audio.js');
+BK.Script.loadlib('GameRes://libs/element/image.js');
+BK.Script.loadlib('GameRes://libs/element/document.js');
+BK.Script.loadlib('GameRes://libs/element/canvas.js');
+BK.Script.loadlib('GameRes://libs/element/other.js');
+BK.Script.loadlib('GameRes://libs/element/XMLHttpRequest.js');
+
+window['XMLHttpRequest'] = XMLHttpRequest;
+
+HTMLElement = _HTMLBaseElemenet;
+Image = window.Image = HTMLImageElement;
+document = window.document = new HTMLDocumentElement();
+
+var canvas = new HTMLMainCanvasElement();
+canvas.id = 'GameCanvas';
+document.body.appendChild(canvas);
+
+var location = window.location = {
+    href: "",
+};
+var console = window.console = {
+    log: function (msg) {
+        BK.Script.log(1, 0, msg);
+    },
+    warn: function (msg) {
+        BK.Script.log(1, 0, msg);
+    },
+    error: function (msg) {
+        BK.Script.log(1, 0, msg);
+    },
+    info: function(msg) {
+        BK.Script.log(1, 0, msg);
+    },
+    debug: function(msg) {
+        BK.Script.log(1, 0, msg);
+    },
+};
+
+window["BK"] = BK;
+window["isQQPlay"] = true;
+alert = window.alert = console.warn;
+window["pageXOffset"] = 0;
+window["pageYOffset"] = 0;
+
+var WebGLRenderingContext = function () {};
+
+// 用于在加载引擎后对一些代码适配
+function initAdapter () {
+
+  var sps = BK.Director.screenPixelSize;
+  window.innerWidth = sps.width;
+  window.innerHeight = sps.height;
+
+  canvas.width = sps.width;
+  canvas.height = sps.height;
+
+
+  // adapter RendererWebGL
+  cc.rendererWebGL.__webGLRendering = cc.rendererWebGL.rendering;
+  cc.rendererWebGL.rendering = function (ctx, cmds) {
+      this.__webGLRendering(ctx, cmds);
+      gl.glCommit();
+  };
+
+  // adapt _runMainLoop
+  cc.game._setAnimFrame = function () {
+      this._lastTime = new Date();
+      var frameRate = this.config[this.CONFIG_KEY.frameRate];
+      this._frameTime = 1000 / frameRate;
+      window.requestAnimFrame = window.requestAnimationFrame;
+      window.cancelAnimFrame = window.cancelAnimationFrame;
+  };
+  cc.game._runMainLoop = function () {
+      var self = this, callback, config = self.config, CONFIG_KEY = self.CONFIG_KEY,
+          director = cc.director,
+          frameRate = config[CONFIG_KEY.frameRate];
+
+      director.setDisplayStats(config[CONFIG_KEY.showFPS]);
+
+      callback = function () {
+          if (!self._paused) {
+              self._intervalId = window.requestAnimFrame(callback);
+              director.mainLoop();
+          }
+      };
+
+      self._intervalId = window.requestAnimFrame(callback);
+      self._paused = false;
+  };
+}
+
+Float32Array.prototype.subarray = function (begin, end) {
+    return new Float32Array(this.buffer, begin, end)
+};
+
+Uint16Array.prototype.subarray = function (begin, end) {
+    return new Uint16Array(this.buffer, begin, end)
+};
+
+//--BK.Canvas------------------------------------------------
+
+var prototype = BK.Canvas.prototype;
+prototype.createImageData = function () {
+    return {
+        data: [],
+        width: 0,
+        height: 0
+    };
+};
+prototype.putImageData = function () {};
+prototype.addEventListener = function () {};
+prototype.createLinearGradient = function () {};
+prototype.setTransform = prototype.transforms;
+var _fillText = prototype.strokeText = prototype.fillText;
+prototype.fillText = function () {
+    this.lineWidth = 0;
+    _fillText.apply(this, arguments);
+};
+prototype.getImageData = function(){
+    return {data : [1, 0, 1, 0]};
+};
+prototype.focus = function(){};
+prototype.getContext = function () {
+    return this;
+};
+Object.defineProperty(prototype, "width", {
+    get: function () {
+        return this.contentSize.width;
+    },
+    set: function (val) {
+        var size = this.contentSize;
+        size.width = val;
+        this.contentSize = size;
+        this.font = "";
+        this.strokeColor = {r:0,g:0,b:0,a:0};
+        this.strokewidth = 0;
+    },
+    enumerable: true,
+    configurable: true
+});
+Object.defineProperty(prototype, "height", {
+    get: function () {
+        return this.contentSize.height;
+    },
+    set: function (val) {
+        var size = this.contentSize;
+        size.height = val;
+        this.contentSize = size;
+        this.font = "";
+        this.strokeColor = {r:0,g:0,b:0,a:0};
+        this.strokewidth = 0;
+    },
+    enumerable: true,
+    configurable: true
+});
+
+var BOLD_REGEX = /bold/g;
+Object.defineProperty(prototype, "font", {
+    get: function () {
+        return this._font || '';
+    },
+    set: function (val) {
+        this._font = val;
+        if (val) {
+            var matchRet = val.match(/(\d*)px/);
+            var size = (matchRet && !isNaN(matchRet[1])) ? parseInt(matchRet[1]) : 20;
+            //console.log("size" + size)
+            this.setTextSize(size);
+            var isBold = BOLD_REGEX.test(val);
+            this.setTextBold(isBold);
+        }
+    },
+    enumerable: true,
+    configurable: true
+});
+
+var tempColor = { r: 0, g: 0, b: 0, a: 1.0};
+function rgbToColor (rgbStr) {
+    if (/^\#/.test(rgbStr)) {
+        if (rgbStr.length === 4) {
+            return {
+                r: parseInt(rgbStr[1] + rgbStr[1], 16) / 255,
+                g: parseInt(rgbStr[2] + rgbStr[2], 16) / 255,
+                b: parseInt(rgbStr[3] + rgbStr[3], 16) / 255,
+                a: parseInt(rgbStr[4] + rgbStr[4], 16),
+            }
+        } else if (rgbStr.length === 7) {
+            return {
+                r: parseInt(rgbStr.substr(1, 2), 16) / 255,
+                g: parseInt(rgbStr.substr(3, 2), 16) / 255,
+                b: parseInt(rgbStr.substr(5, 2), 16) / 255,
+                a: parseInt(rgbStr.substr(7, 2), 16),
+            };
+        } else {
+            return {r: 0, g: 0, b: 0, a: 1};
+        }
+    }
+
+    var strArr = rgbStr.match(/(\d|\.)+/g);
+    if (!strArr || strArr.length > 4 || strArr.length < 3) {
+        return {r: 0, g: 0, b: 0, a: 1};
+    }
+    tempColor.r = strArr[0] / 255 || 0;
+    tempColor.g = strArr[1] / 255 || 0;
+    tempColor.b = strArr[2] / 255 || 0;
+    tempColor.a = strArr[3] || 1;
+    return tempColor;
+}
+
+Object.defineProperty(prototype, "fillStyle", {
+    get: function () {
+        return this._fillStyle || '';
+    },
+    set: function (val) {
+        this._fillStyle = val;
+        this.fillColor = rgbToColor(val);
+    },
+    enumerable: true,
+    configurable: true
+});
+
+Object.defineProperty(prototype, "strokeStyle", {
+    get: function () {
+        return this._strokeStyle || '';
+    },
+    set: function (val) {
+        this._strokeStyle = val;
+        this.strokeColor = rgbToColor(val);
+    },
+    enumerable: true,
+    configurable: true
+});
+
+// requestAnimationFrame requestAnimationFrame
+
+var _mainTicker;
+var requestAnimationFrame = window.requestAnimationFrame = function (callback) {
+    if (!_mainTicker) {
+        _mainTicker = new BK.Ticker();
+        var frameRate = cc.game.config[cc.game.CONFIG_KEY.frameRate];
+        _mainTicker.interval = 60 / frameRate;
+        _mainTicker.setTickerCallBack(function (ts, duration) {
+            if (!cc.game._paused) {
+                BK.inputManager && BK.inputManager.detectGesture();
+                callback();
+            }
+        });
+    }
+    return 1;
+};
+
+var cancelAnimationFrame = window.cancelAnimationFrame = function () {
+    if (_mainTicker) {
+        _mainTicker.dispose();
+        _mainTicker = null;
+    }
+};
+
+// setTimeout, clearTimeout
+
+var _windowTimeIntervalId = 0;
+var _windowTimeFunHash = {};
+var WindowTimeFun = function (code) {
+    this._intervalId = _windowTimeIntervalId++;
+    this._ticker = new BK.Ticker();
+    this._ticker.interval = 1;
+    this._code = code;
+};
+
+WindowTimeFun.prototype.fun = function () {
+    if (!this._code) return;
+    var code = this._code;
+
+    if (typeof code === 'string') {
+        Function(code)();
+    }
+    else if (typeof code === 'function') {
+        code.apply(null, this._args);
+    }
+};
+
+var setTimeout = window.setTimeout = function (code, delay) {
+    var target = new WindowTimeFun(code);
+    if (arguments.length > 2)
+        target._args = Array.prototype.slice.call(arguments, 2);
+    var original = target.fun;
+    target.fun = function () {
+        clearTimeout(this.target._intervalId);
+        original.apply(this.target, arguments);
+    };
+    if (!delay) {
+        delay = 0.001;
+    }
+    target._ticker.setTimeout(function(){
+        try{
+            target.fun.apply(this, arguments);
+        }catch(e){
+            debugger;
+            console.error(e);
+        }
+    }, delay, target);
+    _windowTimeFunHash[target._intervalId] = target;
+    return target._intervalId;
+};
+
+var setInterval = window.setInterval = function(code, delay){
+    var target = new WindowTimeFun(code);
+    if (arguments.length > 2)
+        target._args = Array.prototype.slice.call(arguments, 2);
+    var original = target.fun;
+    target.fun = function () {
+        original.apply(this.target, arguments);
+    };
+    if (!delay) {
+        delay = 0.001;
+    }
+    target._ticker.setInterval(target.fun, delay, target);
+    _windowTimeFunHash[target._intervalId] = target;
+    return target._intervalId;
+};
+
+var clearTimeout = window.clearTimeout = function (intervalId) {
+    var target = _windowTimeFunHash[intervalId];
+    if (target) {
+        target._ticker.removeTimeout(target);
+        target._ticker.dispose();
+        delete _windowTimeFunHash[intervalId];
+    }
+};
+
+var clearInterval = window.clearInterval = function (intervalId) {
+    var target = _windowTimeFunHash[intervalId];
+    if (target) {
+        target._ticker.removeInterval(target);
+        target._ticker.dispose();
+        delete _windowTimeFunHash[intervalId];
+    }
+};
+
+// WebSocket
+var WebSocket = window.WebSocket = BK.WebSocket;
+
+WebSocket.CONNECTING = 0;
+WebSocket.OPEN = 1;
+WebSocket.CLOSING = 2;
+WebSocket.CLOSED = 3;
+
+// adaptation readyState
+// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket#Ready_state_constants
+Object.defineProperty(WebSocket.prototype, "readyState", {
+    get: function () {
+        var readyState = this.getReadyState();
+        //console.log("defineProperty readyState" + readyState)
+        if (readyState === 4 /* ESTABLISHED */)
+            return WebSocket.OPEN;
+        if (readyState === 2 /* HANDSHAKE_REQ */ || readyState === 3 /* HANDSHAKE_RESP */)
+            return WebSocket.CONNECTING;
+        if (readyState === 1 /* CLOSING */)
+            return WebSocket.CLOSING;
+        if (readyState === 0 /* CLOSED */)
+            return WebSocket.CLOSED;
+        return -1;
+    }
+});
+
+// Local Storage
+
+(function _adaptLocalStorage () {
+    var LocalStoragePath = 'GameSandBox://cc_local_storage.json';
+    window.localStorage = {//cc.sys.localStorage
+        _readData: function () {
+            if (!BK.FileUtil.isFileExist(LocalStoragePath)) {
+                return {};
+            }
+            try {
+                var buff = BK.FileUtil.readFile(LocalStoragePath);
+                return JSON.parse(buff.readAsString());
+            }
+            catch (e){
+                debugger;
+                return {};
+            }
+        },
+        _saveData: function (data) {
+            if (!data) return;
+            try {
+                BK.FileUtil.writeFile(LocalStoragePath, JSON.stringify(data));
+            }
+            catch (e){
+                debugger;
+                console.log('save data failed: '+  data);
+            }
+        },
+        getItem: function (key) {
+            var data = this._readData();
+            return data[key] || null;
+        },
+        setItem: function (key, content) {
+            var data = this._readData();
+            data[key] = content;
+            this._saveData(data);
+        },
+        removeItem: function (key) {
+            var data = this._readData();
+            delete data[key];
+            this._saveData(data);
+        },
+        clear: function () {
+            this._saveData({});
+        }
+    };
+})();
+
+// other adapter
+var performance = { now: function() { return BK.Time.timestamp * 1000; } };
+

+ 1 - 1
settings/builder.json

@@ -9,7 +9,7 @@
   "inlineSpriteFrames": true,
   "inlineSpriteFrames_native": true,
   "jailbreakPlatform": false,
-  "md5Cache": true,
+  "md5Cache": false,
   "mergeStartScene": false,
   "oauthLoginServer": "",
   "optimizeHotUpdate": false,