Как вызвать глобальную функцию javascript из c ++ cocos2d-x

У меня есть файл 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();

Теперь, как я могу позвонить 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
}
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector