Creator版本:1.8
工作环境:mac
问题描述
:js自动绑定了一个自己实现的CPP类 jsbTest,自动绑定结果如下
bool js_register_jsbTest_jsbTest(se::Object* obj)
{
//暴露cpp类到JS中
auto cls = se::Class::create(“jsbTest”, obj, nullptr, nullptr);
cls->defineFunction("testlog", _SE(js_jsbTest_jsbTest_testlog)); cls->defineFinalizeFunction(_SE(js_jsbTest_finalize)); cls->install(); JSBClassType::registerClass<jsbTest>(cls);
__jsb_jsbTest_proto = cls->getProto(); __jsb_jsbTest_class = cls;
se::ScriptEngine::getInstance()->clearException(); return true;}
bool register_all_jsbTest(se::Object* obj)
{
// Get the global ns
se::Object* ns = se::ScriptEngine::getInstance()->getGlobalObject();
js_register_jsbTest_jsbTest(ns); return true;}
在js代码中调用如下
// use this for initialization onLoad: function () { this.label.string = this.text; var tmp = new jsbTest(); tmp.testlog(); },
使用模拟器预览当前场景,报错:
Simulator: JS: [WARN]: Sorry, lineHeight of system font not supported on JSB.
Simulator: jsb: ERROR: File /Users/tuyou/tcz/study/cocos2d-x-lite/cocos/scripting/js-bindings/auto/jsb_jsbTest_auto.cpp: Line: 12, Function: js_jsbTest_jsbTest_testlog
Simulator: js_jsbTest_jsbTest_testlog : Invalid Native Object
Simulator: [ERROR] Failed to invoke js_jsbTest_jsbTest_testlog, location: /Users/tuyou/tcz/study/cocos2d-x-lite/cocos/scripting/js-bindings/auto/jsb_jsbTest_auto.cpp:22
Simulator: JS: Activate: 130.57399999999961ms
打IOS包测试,跟cretor中预览结果一样
但是使用安卓打包,可以正常调用到。
cocos creator模拟器已重新生成
**
希望最终达成效果
**:cocos creator中也可以正常调用C++的绑定类
请熟悉这个的同学帮忙解答下该如何处理,谢谢~


