HomeMoreCtrl.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const AlertManager = require('../utils/AlertManager');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. showNode: cc.Node,
  6. blackMaskNode: cc.Node
  7. },
  8. // LIFE-CYCLE CALLBACKS:
  9. onLoad () {
  10. let self = this;
  11. this.handleShowMore = _.throttle(() => {
  12. if (self.showNode.active) {
  13. self.showNode.active = false;
  14. self.blackMaskNode.active = false;
  15. } else {
  16. self.showNode.active = true;
  17. self.blackMaskNode.active = true;
  18. }
  19. }, 500, true);
  20. this.handleShowSetting = _.debounce((event) => {
  21. AlertManager.showGameSetting();
  22. self.showOrHideMore();
  23. }, 1000, true)
  24. GameEvent.on('show_home_more', this, () => {
  25. this.node.active = true;
  26. });
  27. GameEvent.on('hide_home_more', this, () => {
  28. this.node.active = false;
  29. });
  30. },
  31. onDestroy() {
  32. GameEvent.off('show_home_more',this);
  33. GameEvent.off('hide_home_more',this);
  34. },
  35. start () {
  36. },
  37. showOrHideMore() {
  38. this.handleShowMore();
  39. },
  40. showSetting() {
  41. this.handleShowSetting();
  42. }
  43. // update (dt) {},
  44. });