QuestTab.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. bgFrames: [cc.SpriteFrame],
  5. noticeNode: cc.Node
  6. },
  7. onLoad () {
  8. },
  9. init (quest, isMain) {
  10. this.quest = quest;
  11. this.isMain = isMain;
  12. if (this.isMain) {
  13. GameEvent.on('quest_main_notice', this, (isCancel) => {
  14. if (isCancel) {
  15. this.noticeNode.active = false;
  16. } else {
  17. this.noticeNode.active = true;
  18. }
  19. });
  20. } else {
  21. GameEvent.on('quest_daily_notice', this, (isCancel) => {
  22. if (isCancel) {
  23. this.noticeNode.active = false;
  24. } else {
  25. this.noticeNode.active = true;
  26. }
  27. });
  28. }
  29. },
  30. show () {
  31. this.getComponent(cc.Button).interactable = false;
  32. this.getComponent('cc.Sprite').spriteFrame = this.bgFrames[1]
  33. },
  34. hide () {
  35. this.getComponent(cc.Button).interactable = true;
  36. this.getComponent('cc.Sprite').spriteFrame = this.bgFrames[0]
  37. },
  38. onDestroy() {
  39. GameEvent.off('quest_main_notice', this);
  40. GameEvent.off('quest_daily_notice', this);
  41. }
  42. // update (dt) {},
  43. });