HomeMoreCtrl.js 1.4 KB

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