const DWTool = require("../utils/DWTool"); const ArtistManager = require("../utils/ArtistManager"); cc.Class({ extends: cc.Component, properties: { starDarkNode: cc.Node, starHeadNode: cc.Node, countNode: cc.Node, countLabel: cc.Label, isUnlocked: { get: function() { if (!this._isUnlocked) { this._isUnlocked = false; } return this._isUnlocked; }, set: function(value) { this._isUnlocked = value; if (this._isUnlocked) { this.starHeadNode.active = true; this.countNode.active = true; this.starDarkNode.active = false; } else { this.starHeadNode.active = false; this.countNode.active = false; this.starDarkNode.active = true; } } }, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => { this.showStarDesc(); }, 1000, true), this); }, start () { }, configData(starInfo) { this.starInfo = starInfo; if (starInfo.starCount > 0 ) { this.isUnlocked = true; this.countLabel.string = `${starInfo.starCount}/${starInfo.starCount}`; } else { this.isUnlocked = false; } let imageId = 50000 + starInfo.starId; ArtistManager.loadStarBlackAvatarSpriteFrame(imageId, this.starDarkNode.getComponent('cc.Sprite')); ArtistManager.loadStarAvatarSpriteFrame(imageId, this.starHeadNode.getComponent('cc.Sprite')); }, showStarDesc() { if (this.isUnlocked) { GameEvent.fire('show_star_desc', this.starInfo); } }, // update (dt) {}, });