GithubHelp home page GithubHelp logo

creatorprotobuf.6.8.0.js's Introduction

#protobufjs 本插件基于protobufjs 6.8.0版本,主要针对自己的项目进行了一点点更改,使之能正常的在跨平台上面使用

#适用范围: cocos creator 1.6版本(1.6之前的版本没有测试过), 如果有问题可以直接联系我QQ657542753

#用法: 导入项目,并设置为插件(ps:不要问我怎么导入为插件,不然我打死你!官方文档是有相关介绍的)

#更改 #game对象是一个自定义的全局变量,如果大家喜欢用全局变量,可以在以下目录的文件中添加以下内容 window.game = {}

需要添加的文件: creator安装目录下: /Resources/static/simulator/main.js //该目录是用于模拟器的 /Resources/static/preview-templates/boot.js //web /Resources/static/build-templates/shares/main.js //打包模板

function pool(alloc, slice, size) {
    var SIZE   = size //|| 8192;
    var MAX    = SIZE >>> 1;
    var slab   = null;
    var offset = SIZE;
    return function pool_alloc(size) {
        if (size < 1 || size > MAX)
            return alloc(size);
        if (offset + size > SIZE) {
            slab = alloc(SIZE);
            offset = 0;
        }
        var buf = slice.call(slab, offset, offset += size);
        if (offset & 7) // align to 32 bit
            offset = (offset | 7) + 1;
        return buf;
    };
}
function fetch(filename, options, callback) {
if (typeof options === "function") {
    callback = options;
    options = {};
} else if (!options)
    options = {};

if (!callback)
    return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this

// if a node-like filesystem is present, try it first but fall back to XHR if nothing is found.
console.log("cc.sys.isNative)",cc.sys.isNative)
if (cc.sys.isNative)
    try {
        // 这边通过解析文件名字,然后用cc.loader.load来加载文件
        var start_idx = filename.lastIndexOf("/") + 1
        var end_idx = filename.lastIndexOf(".")
        var name = filename.substring(start_idx, end_idx)
        var data = game.ResMgr.getProto(name)
        return callback(null, data.content)
    } catch (e) {
        return null;
    }
// use the XHR version otherwise.
return fetch.xhr(filename, options, callback);

}

// name = applyCase(name)

creatorprotobuf.6.8.0.js's People

Contributors

catfishgamer avatar

Watchers

James Cloos avatar 大菠萝 avatar

Forkers

jason201266

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.