const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey; cc.Class({ extends: cc.Component, properties: { // actGiftFrames: { tooltip: '奖品大图', default: [], type: [cc.SpriteFrame] }, actGiftSprite: cc.Sprite, actGiftLabel: cc.Label, zIndex: { default: 0, notify(oldValue) { //减少无效赋值 if (oldValue === this.zIndex) { return; } this.node.zIndex = this.zIndex; } }, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.giftMap = ['coin', 'diamond', 'ticket']; this.node.zIndex = this.zIndex; }, init(type, showText, spriteFrame) { if (spriteFrame) { this.actGiftSprite.spriteFrame = spriteFrame; if (showText) { this.actGiftLabel.node.active = true; this.actGiftLabel.string = showText; } else { this.actGiftLabel.node.active = false; } } else { this.giftMap.forEach((value, index) => { if (type == value) { this.actGiftSprite.spriteFrame = this.actGiftFrames[index]; if (showText) { this.actGiftLabel.node.active = true; this.actGiftLabel.string = showText; } else { this.actGiftLabel.node.active = false; } } }) } }, hideActGift() { this.node.destroy(); }, start () { }, // update (dt) {}, });