How to convert STRING to FUNCTION in cocos2dx js?

How to convert STRING to FUNCTION in cocos2dx js?
0.0 0

#1

Hello there,

I am recently working on my game. I wanted to turn any string to function just loop call. But I don’t know how to implement it.

Do anyone have an idea about it? Please help.

thank.


#2

Try this:

let myString = cc.callFunc(() => {
            let text = "Sting Value";
this.node.getComponent(cc.Label).string = text;
});

#3

That’s a pure javascript thing:

var newFunc = eval("var retVal = function(){ console.log('Hi there!') }; retVal;");
newFunc();