COCOS2DX JSB CPP调用JS的方法

1\调用某个对象的方法
JSContext* context = ScriptingCore::getInstance()->getGlobalContext();
jsval val[] = {
val[0] = int32_to_jsval(context, 1),
val[1] =UINT_TO_JSVAL(2)
};
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), “callback”, 2, val);

2、调用全局的方法

ScriptingCore::getInstance()->evalString(‘window.functionName(“1″,”2”)’);

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *