123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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 = `<b><color=#773811>${text}</color></b>`;
- 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) {},
- });
|