const DWTool = require("../utils/DWTool"); cc.Class({ extends: cc.Component, properties: { ///背景图 bgNode: cc.Sprite, /// 明星图像 starIcon: cc.Sprite, }, init(backgroudId, propId = 0) { /// 说明不是明星 if (propId <= 0) { let path = './textures/draw/' + backgroudId; DWTool.loadResSpriteFrame(path) .then((spriteFrame) => { this.starIcon.spriteFrame = spriteFrame; }); if (backgroudId === 700001) { this.starIcon.node.width = 64; this.starIcon.node.height = 58; } else if (backgroudId === 700002) { this.starIcon.node.width = 55; this.starIcon.node.height = 69; }else { this.starIcon.node.width = 194; this.starIcon.node.height = 194; } } else { let imageId = 50000 + propId; DWTool.loadResSpriteFrame(`./textures/star_handbook/${imageId}`) .then((spriteFrame) => { this.starIcon.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); let path = './textures/draw/' + backgroudId; DWTool.loadResSpriteFrame(path) .then((spriteFrame) => { this.bgNode.spriteFrame = spriteFrame; }); } }, // LIFE-CYCLE CALLBACKS: onLoad () { }, start () { }, });