const DWTool = require("../utils/DWTool"); cc.Class({ extends: cc.Component, properties: { ///背景图 bgNode: cc.Sprite, /// 明星图像 starIcon: cc.Sprite, }, init(backgroudId, propId = 0) { this.loadBackGroud(backgroudId); if (propId <= 0) { return; } let imageId = 50000 + propId; DWTool.loadResSpriteFrame(`./textures/star_handbook/${imageId}`) .then((spriteFrame) => { this.starIcon.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); }, loadBackGroud(backgroudId) { let path = './textures/draw/bg0' + (backgroudId + 1); DWTool.loadResSpriteFrame(path) .then((spriteFrame) => { this.bgNode.spriteFrame = spriteFrame; }); }, // LIFE-CYCLE CALLBACKS: onLoad () { }, start () { }, });