// Learn cc.Class: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { sp_icon: { default: null, type: cc.Sprite }, lb_name: { default: null, type: cc.Label }, lb_des: { default: null, type: cc.Label }, nd_bg: { default: null, type: cc.Node }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, initdata(data) { this.lb_name.string = data.skill_name; this.lb_des.string = data.des; this.lb_des._updateRenderData(true); cc.loader.loadRes("icons/"+data.skill_icon, cc.SpriteFrame, function(err, res) { if (!err && this.isValid) { this.sp_icon.spriteFrame = res; } }.bind(this)); var height = (this.lb_des.node.getContentSize().height/2)+50; this.nd_bg.height = height }, // update (dt) {}, });