2

I am just wondering how to put another js API library( in my case, i want to put the smartfoxserver javascript API library) in cocos creator? because what i did in cocos2d-js, i just need to add it in project.json, and I am wondering if i can do same way in cocos creator or another way?

thank you in advance

reference question from:

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

4

2 回答 2

3

再会

您可以使用模块导出

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

然后使用从其他脚本访问它

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

干杯

于 2016-10-26T10:52:01.540 回答
0

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

于 2017-02-25T16:17:01.290 回答