批量给按钮增加监听事件,请问如何获取属性类型?
children instanceof cc.Button
这种写法好像不行
onLoad () {
debugger;
var _self = this;
var childrens = this.node.children;
for(var i=0;i<this.node.childrenCount;i++){
var children = childrens[i];
if(children instanceof cc.Button){
children[i].node.on(cc.Node.EventType.TOUCH_END, function (event) {
_self.setAnswer(event);
}, this);
}
}
}