tofacebook.com -专业IT技术社区(指牛堂) 【百家号】脸书百科,OC和Cocos-js的互相调用 Web程序 - 指牛堂-专业IT技术平台
85°

【百家号】脸书百科,OC和Cocos-js的互相调用 Web程序

标签:number   color   nsstring   class   cal   string   sea   record   cname   

OC调用cocos-js

#import "ScriptingCore.h"
#import "cocos2d.h"
#include "scripting/js-bindings/manual/ScriptingCore.h"
#include "scripting/js-bindings/manual/jsb_conversions.hpp"
#include "scripting/js-bindings/jswrapper/SeApi.h"
#define JSCallBackHasVoice @"cc.director.getScene().getChildByName(‘Canvas‘).getComponent(‘OCRecorder‘).hasVoice"
//hasVoice是cocos-js的方法
+ (void)JsCallBack:(NSString *)funcNameStr WithIndex:(NSInteger)index{
    std::string funcName = [funcNameStr UTF8String];
    NSString *numberStr  = [NSString stringWithFormat:@"%ld",index];
    std::string coins = [numberStr UTF8String];
    std::string jsCallStr = cocos2d::StringUtils::format("%s(\"%s\");",funcName.c_str(), coins.c_str());
    se::ScriptEngine::getInstance()->evalString(jsCallStr.c_str());
}

 

OC和Cocos-js的互相调用

标签:number   color   nsstring   class   cal   string   sea   record   cname   

原文地址:https://www.cnblogs.com/wycstudy/p/9379240.html


本文由百家号/熊掌号作者上传并发布,百家号仅提供信息发布平台。文章仅代表作者个人观点,不代表百度立场。

已有 0 条评论

    我有话说: