var gameConfig = require("gameConfig") cc.Class({ extends: cc.Component, properties: { nd_lvup: { default: null, type: cc.Node }, nd_close: { default: null, type: cc.Node }, nd_open: { default: null, type: cc.Node }, sp_icon: { default: null, type: cc.Sprite }, lb_close: { default: null, type: cc.Label }, lb_open: { default: null, type: cc.Label }, lb_lv: { default: null, type: cc.Label }, }, // LIFE-CYCLE CALLBACKS: onLoad() { cc.Notifier.on("talent_lvup", this, this.talent_lvup.bind(this)); }, onDestroy() { cc.Notifier.off("talent_lvup", this); }, talent_lvup(v){ if(v==this.tid){ this.initdata(v) this.onclick() } }, initdata(id) { this.tid = id this.nd_close.active = this.nd_lvup.active = this.nd_open.active = false var leanxp = cc.playerData.getLearnedTalent(id) this.nowlv = 1 this.open = false if (leanxp) { this.open = true this.nd_open.active = true this.nowlv = leanxp.talent_lv } else { this.nd_close.active = true } this.nowdata = cc.playerData.xinpian[id][this.nowlv - 1] this.lb_close.string = this.nowdata.name this.lb_open.string = this.nowdata.name this.lb_lv.string = "LV." + this.nowlv this.nextdata = cc.playerData.xinpian[id][this.nowlv] cc.loader.loadRes("itemicon/chips/" + this.nowdata.icon, cc.SpriteFrame, function(err, res) { if (!err && this.isValid) { this.sp_icon.spriteFrame = res; } }.bind(this)); if(this.open){ if(this.nextdata){ var isenough = true var itemarr = this.nowdata.cost.split('|') for(var i=0;i