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

2 Answers2

3

good day

you can use module exports

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

then access it from other scripts using

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

cheers

0

i just scan the smartfoxserver. it use the websocket that is fine just drag an drop the SFS2X_API_JS.js to the project and require it and init it maybe you would use window.xxx to set the connection handler as global value

林海威
  • 49
  • 2