ArtistTrainItemSkill.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const { ArtistTrainItemSkillStyle } = require('../utils/GameEnum');
  2. const DWTool = require("../utils/DWTool");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. skillSprite: cc.Sprite,
  7. title: cc.Label,
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. init(style, addition) {
  11. this.style = style;
  12. this.title.string = `+${addition}`;
  13. switch (style) {
  14. case ArtistTrainItemSkillStyle.Ability: // 能力加成
  15. DWTool.loadResSpriteFrame('./artistTrain/artist_train_ability')
  16. .then((spriteFrame) => {
  17. this.skillSprite.spriteFrame = spriteFrame;
  18. });
  19. break;
  20. case ArtistTrainItemSkillStyle.Charm: // 魅力加成
  21. DWTool.loadResSpriteFrame('./artistTrain/artist_train_charm')
  22. .then((spriteFrame) => {
  23. this.skillSprite.spriteFrame = spriteFrame;
  24. });
  25. break;
  26. case ArtistTrainItemSkillStyle.Effect: // 影响力
  27. DWTool.loadResSpriteFrame('./artistTrain/artist_train_effect')
  28. .then((spriteFrame) => {
  29. this.skillSprite.spriteFrame = spriteFrame;
  30. });
  31. break;
  32. default:
  33. break;
  34. }
  35. this.skillSprite.node.getComponent(cc.Widget).updateAlignment();
  36. this.title.node.getComponent(cc.Widget).updateAlignment();
  37. },
  38. onLoad () {
  39. },
  40. start () {
  41. },
  42. // update (dt) {},
  43. });