{
var file = cc.find(‘画布/ui/选项卡/内容’)
var texture = value.assets[0]
var ma = value.ui[1]
for (var i = 0; i < ma.length; i++) {
var iii = cc.instantiate(value.file.ka_cao)
file.addChild(iii)
var sprite1 = iii.getComponent(cc.Sprite)
var fun = function () {
var i = i
return function (event: cc.Event.EventTouch) {
value.ui[0](event.target)
var node: cc.Node = value.file.dian_shi_ji.children[0]
var index1 = ma[i][0]
var index2 = ma[i][1]
node.getComponent('ui').addLabel(audioLabel[index1][index2]) //注射功能
}
}
iii.on(cc.Node.EventType.TOUCH_START, fun(), this)
sprite1.spriteFrame = texture.getSpriteFrames()[i]
iii.width = 100
iii.height = 100
}
}
闭包的化者变量也经不去,