how to call javascript function from c++ in cocos2d-x -
In my cocos2d-x js project, I force the c ++ function to use c + In this way, I see an IOS alert and show it as my JS code, but when the user clicks the OK button, I can pass the event to JS, I tried and rounded all in 2 days, but I Can not do this, if someone knows what the solution is, please help me, Hut Many thanks!
You have not provided any code, so it is difficult to give you specific help, but in this way Should give something in some direction:
Poo.h
class JSObject; Square poo: cocos2d :: CCNode {public: static zero hello (JSObject * target, std :: string selector); } Poo.cpp
Poo :: hello (JSObject * target, std :: string selector) {if (target) {js_proxy_t * p; JS_GET_PROXY (P, Target); If (! P) {return; } Jaswal Ratwal; JSL Data Val = Std_String_to_Jeswal (Scriptingcore :: getInstance () - & gt; getGlobalContext (), "Hello World"); Scriptingcore: Receive () - & gt; With performance work (OBJECT_TO_JSVAL (P-> OBJ), selector cistrated (), 1, and datawal, and retal); }} Then, in your JS file:
var demo = cc.Node.extend ({ctor: function () {this._super ( ); // Normal Init stuff Poo.hello (this, "myCallback");}, myCallback: function (msg) {cc.log ("I received the message from C ++:" + msg);}} );
Comments
Post a Comment