【问题标题】:How to put external js API in cocos creator?如何在 cocos creator 中放置外部 js API?
【发布时间】:2016-10-08 02:14:44
【问题描述】:

我只是想知道如何在 cocos creator 中放置另一个 js API 库(在我的情况下,我想放置 smartfoxserver javascript API 库)?因为我在 cocos2d-js 中所做的,我只需要在 project.json 中添加它,我想知道我是否可以在 cocos creator 中执行相同的方式或其他方式?

提前谢谢你

参考问题来自:

http://discuss.cocos2d-x.org/t/how-to-put-another-js-api-library-in-cocos-creator/32598

【问题讨论】:

    标签: javascript html cocoscreator


    【解决方案1】:

    美好的一天

    您可以使用模块导出

    var x = {
    /*
    your stuff
    */
    };
    module.exports = x;
    

    然后使用其他脚本访问它

    var externalScript=require("name of the script with module.exports");
    

    干杯

    【讨论】:

      【解决方案2】:

      我只是扫描 smartfoxserver。它使用很好的 websocket 只需将 SFS2X_API_JS.js 拖放到项目中并要求它并初始化它也许你会使用 window.xxx 将连接处理程序设置为全局值

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多