Hello everyone,
I’m new in Cocos2d-x framework, I’m trying to enumerate the children nodes using Node.enumerateChildren(), so I need get nodes that their name starting with “btnA_D#” where “#” indicates the button number, e.g: btnA_D1, btnA_D2, etc. Then I’m using a regular expression like this "btnA_D[0-9]+". This is my code:
var mainscene = ccs.load(res.MainScene_json);
this.addChild(mainscene.node);
var buttons = new Array();
var cll = function (node){
buttons.push(node);
console.log(node);
};
mainscene.node.enumerateChildren("btnA_D[0-9]+", cll);
It doesn’t work, after I debugged and I found in the line 2541 in the “CCNode.js” file, that:
(child._name.indexOf(searchName) !== -1){
I think that indexOf(searchName) doesn’t have the correctly behaviour for satisfy the description in documentation. I replaced that line for this:
var patt = new RegExp(searchName);
if (patt.test(child._name) !== false){
And it solved my problem. So I think that is a bug but what do you think?. Thanks in advance and excuse me for my bad english.