cocosCreator中Protobuf的简单使用

mark一下

在调试matchvs的demo时,里面的protobuf在浏览器上正常,但发布到微信小游戏就报错了。不知道是什么问题,好奇怪。Cannot read property ‘dcodeIO’ of undefined
TypeError: Cannot read property ‘dcodeIO’ of undefined
at http://127.0.0.1:28959/game/src/assets/common/script/basic/rankNetwork/ProtoBuf.js:6:47
at http://127.0.0.1:28959/game/src/assets/common/script/basic/rankNetwork/ProtoBuf.js:7:3
at require (http://127.0.0.1:28959/game/dev/WAGame.js:2:96033)

=========================
mstType.js

“use strict”;
cc._RF.push(module, ‘57b2cIfIk5HLYmy1eO/Sp4Y’, ‘msgType’);
// common/script/basic/rankNetwork/msgType.js

“use strict”;

var protocol = dcodeIO.ProtoBuf.newBuilder({
“populateAccessors”: true
})[‘import’]({
“package”: “protocol”,
“syntax”: “proto2”,

================================
Protobuf.js

/**

  • @license long.js © 2013 Daniel Wirtz dcode@dcode.io

  • Released under the Apache License, Version 2.0

  • see: https://github.com/dcodeIO/long.js for details
    */
    (function(global, factory) {

    console.log(“global-1:”,global);

    (global[“dcodeIO”] = global[“dcodeIO”] || {})[“Long”] = factory();

    console.log(“global-2:”,global);

    /* AMD / if (typeof define === ‘function’ && define[“amd”])
    define([], factory);
    /
    CommonJS / else if (typeof requireJS === ‘function’ && typeof module === “object” && module && module[“exports”])
    module[“exports”] = factory();
    /
    Global */ else
    (global[“dcodeIO”] = global[“dcodeIO”] || {})[“Long”] = factory();

})(this, function() {

学习了,大佬