const { ArtistTrainItemSkillStyle } = require('../utils/GameEnum'); const DWTool = require("../utils/DWTool"); cc.Class({ extends: cc.Component, properties: { skillSprite: cc.Sprite, title: cc.Label, upSprite: cc.Sprite }, // LIFE-CYCLE CALLBACKS: init(style) { this.style = style; switch (style) { case ArtistTrainItemSkillStyle.Ability: // 能力加成 this.title.string = "能力"; DWTool.loadResSpriteFrame('./artistTrain/artist_train_ability') .then((spriteFrame) => { this.skillSprite.spriteFrame = spriteFrame; }); this.node.width = 94; break; case ArtistTrainItemSkillStyle.Charm: // 魅力加成 this.title.string = "魅力"; DWTool.loadResSpriteFrame('./artistTrain/artist_train_charm') .then((spriteFrame) => { this.skillSprite.spriteFrame = spriteFrame; }); this.node.width = 100; break; case ArtistTrainItemSkillStyle.Effect: // 影响力 this.title.string = "影响力"; DWTool.loadResSpriteFrame('./artistTrain/artist_train_effect') .then((spriteFrame) => { this.skillSprite.spriteFrame = spriteFrame; }); this.node.width = 114; break; default: break; } this.skillSprite.node.getComponent(cc.Widget).updateAlignment(); this.title.node.getComponent(cc.Widget).updateAlignment(); this.upSprite.node.getComponent(cc.Widget).updateAlignment(); }, onLoad () { }, start () { }, // update (dt) {}, });