const GameNotificationKey = require('./utils/GameEnum').GameNotificationKey; cc.Class({ extends: cc.Component, properties: { zIndex: { default: 0, notify(oldValue) { //减少无效赋值 if (oldValue === this.zIndex) { return; } this.node.zIndex = this.zIndex; } }, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.node.zIndex = this.zIndex; this._playing = false; this.colorBarSkeletion = this.node.getComponent(sp.Skeleton); this.colorBarSkeletion.node.active = false; this.colorBarSkeletion.paused = true; GameEvent.on(GameNotificationKey.PlaySuccessAnimation, this, () => { if (this._playing) { return; } this.colorBarSkeletion.node.active = true; this.colorBarSkeletion.paused = false; this._playing = true; let animKeyArray = ['caidai1', 'caidai2']; let random = Math.floor(Math.random() * 2); this.colorBarSkeletion.setAnimation(0, animKeyArray[random], false); this.colorBarSkeletion.setCompleteListener(() => { this.colorBarSkeletion.node.active = false; this.colorBarSkeletion.paused = true; this._playing = false; }); }); }, onDestroy() { GameEvent.off(GameNotificationKey.PlaySuccessAnimation, this) }, start () { }, // update (dt) {}, });