Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有和cocos2d-js native模式下 整合的事例吗 #3

Open
perzy opened this issue Jul 24, 2015 · 2 comments
Open

有和cocos2d-js native模式下 整合的事例吗 #3

perzy opened this issue Jul 24, 2015 · 2 comments

Comments

@perzy
Copy link

perzy commented Jul 24, 2015

No description provided.

@fantasyni
Copy link

就是放在 project.json 里面直接引用就行了

@perzy
Copy link
Author

perzy commented Jul 27, 2015

@fantasyni 那 socket.io 库 是用 socket.io 还是 socket.io-client
我这边没有弄成功。

是这样吗?
https://github.com/NetEase/pomelo-cocos2d-js
这个包的index.js文件修改为下面的

var Util = require('util');

function checkCocos2dJsb() {
    if (typeof cc !== 'undefined' && cc && cc.sys && cc.sys.isNative) {
        return true;
    }

    return false;
}

var Root;
(function() {
    Root = this;
}());

if (checkCocos2dJsb()) {
    var console = cc;
    Root.console = console;
    cc.formatStr = Util.format;
}

var io = require('socket.io-client');
Root.io = io;
var pomelo = require('pomelo-jsclient-socket.io');
Root.pomelo = pomelo;

然后在 cocos2d-js native里面用 require('./pomelo-cocos2d-js/index.js')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants