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