我有一个如下的javascript文件:
var helloWorld = function(age, name) {
// do something
cc.log("age=%d, name=%s", age, name);
};
var MyObject = cc.Class.extend({
ctor: function() {},
testFunc: function(str) {
cc.log("testFunc: str=%s", str);
}
});
var myObject = new MyObject();
现在,如何在c ++中调用helloWorld
函数和myObject.testFunc
#include "cocos2d.h"
#include "scripting/js-bindings/manual/js_bindings_core.h"
#include "scripting/js-bindings/manual/cocos2d_specifics.hpp"
class MyCppObject {
public:
MyCppObject() {}
void callJavascript() {
int age = 20;
std::string name = "cocos2dx";
std::string str = "xxx";
// TODO: how can I call `helloWorld` function and `myObject.testFunc` in c++ with arguments
}
}