When do you invoke this function ? Maybe before the initialization of ScriptingCore ?
Besides, the logic of js function call is not correct, msgFromC is the class, and call is its property function, so sc->executeFunctionWithOwner(nsval,"call"); won’t find the call function, you should do the following to get it work:
var MsgFromC = cc.Node.extend({
ctor: function() {
this._super();
},
call: function(msg) {
cc.log("I got a message back from C++: " + msg);
}
});
var msgFromC = new MsgFromC();
thanks, problem solved
because I call cToJs->call() right after android onCreate() method.
but at that time, game lib is not called, so sc is not started.
I call cToJs->call() after game start, and change the js code as you mentioned, everything works fine
The solution you have mentioned here is old as in current version of cocos creator i didn’t find these above function. Do you have latest code for current version of cocos creator ?