DrawStarContent.js 945 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. this.loadBackGroud(backgroudId);
  12. if (propId == 0) {
  13. return;
  14. }
  15. let imageId = 50000 + propId;
  16. DWTool.loadResSpriteFrame(`./textures/star_handbook/${imageId}`)
  17. .then((spriteFrame) => {
  18. this.starIcon.spriteFrame = spriteFrame;
  19. }).catch((err) => {
  20. console.log(err);
  21. });
  22. },
  23. loadBackGroud(backgroudId) {
  24. let path = './textures/draw/bg0' + (backgroudId + 1);
  25. DWTool.loadResSpriteFrame(path)
  26. .then((spriteFrame) => {
  27. this.bgNode.spriteFrame = spriteFrame;
  28. });
  29. },
  30. // LIFE-CYCLE CALLBACKS:
  31. onLoad () {
  32. },
  33. start () {
  34. },
  35. });