AdditionTips.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. showRichText: cc.RichText,
  6. showSpriteFrame: [cc.SpriteFrame],
  7. tipsSprite: cc.Sprite
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad () {
  11. // this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  12. // this.close();
  13. // }, 1000, true), this);
  14. },
  15. start () {
  16. },
  17. // type:0为点击加成,1为生产加成提示
  18. show(text, type) {
  19. if (!this.node.active) {
  20. this.node.active = true;
  21. this.node.runAction(cc.moveBy(0.3, this.node.width, 0));
  22. if (this.timer) {
  23. clearInterval(this.timer);
  24. }
  25. } else {
  26. if (this.timer) {
  27. clearInterval(this.timer);
  28. }
  29. }
  30. this.timer = setInterval(() => {
  31. this.close();
  32. }, 1000);
  33. this.showRichText.string = `<b><color=#773811>${text}</color></b>`;
  34. this.tipsSprite.spriteFrame = this.showSpriteFrame[type];
  35. },
  36. close() {
  37. if (this.timer) {
  38. clearInterval(this.timer);
  39. }
  40. let finish = cc.callFunc(() => {
  41. this.node.active = false;
  42. });
  43. this.node.runAction(cc.sequence(cc.moveBy(0.3, -this.node.width, 0), finish));
  44. },
  45. // update (dt) {},
  46. });