DrawStarContent.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const DWTool = require("../utils/DWTool");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. ///背景图
  6. bgNode: cc.Sprite,
  7. /// 明星图像
  8. starIcon: cc.Sprite,
  9. },
  10. init(backgroudId, propId = 0) {
  11. /// 说明不是明星
  12. if (propId <= 0) {
  13. let path = './textures/draw/' + backgroudId;
  14. DWTool.loadResSpriteFrame(path)
  15. .then((spriteFrame) => {
  16. this.starIcon.spriteFrame = spriteFrame;
  17. });
  18. if (backgroudId === 700001) {
  19. this.starIcon.node.width = 64;
  20. this.starIcon.node.height = 58;
  21. } else if (backgroudId === 700002) {
  22. this.starIcon.node.width = 55;
  23. this.starIcon.node.height = 69;
  24. }else {
  25. this.starIcon.node.width = 194;
  26. this.starIcon.node.height = 194;
  27. }
  28. } else {
  29. let imageId = 50000 + propId;
  30. DWTool.loadResSpriteFrame(`./textures/star_handbook/${imageId}`)
  31. .then((spriteFrame) => {
  32. this.starIcon.spriteFrame = spriteFrame;
  33. }).catch((err) => {
  34. console.log(err);
  35. });
  36. let path = './textures/draw/' + backgroudId;
  37. DWTool.loadResSpriteFrame(path)
  38. .then((spriteFrame) => {
  39. this.bgNode.spriteFrame = spriteFrame;
  40. });
  41. }
  42. },
  43. // LIFE-CYCLE CALLBACKS:
  44. onLoad () {
  45. },
  46. start () {
  47. },
  48. });