const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey; cc.Class({ extends: cc.Component, properties: { showRichText: cc.RichText, showSpriteFrame: [cc.SpriteFrame], tipsSprite: cc.Sprite }, // LIFE-CYCLE CALLBACKS: onLoad () { // this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => { // this.close(); // }, 1000, true), this); }, start () { }, // type:0为点击加成,1为生产加成提示 show(text, type) { if (!this.node.active) { this.node.active = true; this.node.runAction(cc.moveBy(0.3, this.node.width, 0)); if (this.timer) { clearInterval(this.timer); } } else { if (this.timer) { clearInterval(this.timer); } } this.timer = setInterval(() => { this.close(); }, 1000); this.showRichText.string = `${text}`; this.tipsSprite.spriteFrame = this.showSpriteFrame[type]; }, close() { if (this.timer) { clearInterval(this.timer); } let finish = cc.callFunc(() => { this.node.active = false; }); this.node.runAction(cc.sequence(cc.moveBy(0.3, -this.node.width, 0), finish)); }, // update (dt) {}, });