1、oc调用cocos2d Js
NSMutableString * nsmString = [NSMutableString string];
[nsmString appendString: @"g_WeiXinLogin("];
[nsmString appendFormat:@"\"%@\"",openID];
[nsmString appendFormat:@",\"%@\"",token];
[nsmString appendFormat:@",isbind];
[nsmString appendString: @")"];
Nsstring *funString = [Nsstring stringWithString:nsmString];
NSLog(@"===== funString:%@",funString);
const char * funchar = [funString UTF8String];
//oc调用Js
Scriptingcore * sc = Scriptingcore::getInstance();
Jsval outVal;
sc->evalString(funchar,&outVal);
2、cocos2d Js 调用oc
var ret = Jsb.reflection.callStaticmethod("NativeOcclass",
"callNativeUIWithTitle:andContent:",
"cocos2d-Js",
"Yes! you call a Native UI from Reflection");
3、cocos2d Js 调用androID
Jsb.reflection.callStaticmethod("org/cocos2dx/JavaScript/Test","hello","(Ljava/lang/String;)V","this is a message from Js");
4、androID调用 cocos2d Js
Cocos2dxJavaScriptJavaBrIDge.evalString("g_SmsautoWrite(\""+smsCode+"\")");
参考网站:官网http://www.cocos2dx.net/post/254
总结以上是内存溢出为你收集整理的cocos2d js 对android和ios混编记录全部内容,希望文章能够帮你解决cocos2d js 对android和ios混编记录所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)