MenuAction.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { _decorator, Component, director, Node, tween } from 'cc';
  2. import { Global } from './Global';
  3. import { Clips } from './Enums';
  4. import { AudioMgr } from './AudioMgr';
  5. import { BasePage } from './BasePage';
  6. import { AdManger } from './ad/AdManger';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('MenuAction')
  9. export class MenuAction extends BasePage {
  10. @property({ type: Node })
  11. xxx_node: Node
  12. start() {
  13. super.start();
  14. }
  15. update(deltaTime: number) {
  16. }
  17. private set_xxx() {
  18. this.xxx_node.active = !Global.sound_switch;
  19. }
  20. on_off_sound() {
  21. AudioMgr.ins.playSound(Clips.btn_1);
  22. Global.sound_switch = !Global.sound_switch;
  23. this.set_xxx();
  24. }
  25. /**
  26. * show menu plant
  27. */
  28. open() {
  29. super.open();
  30. //show interstial
  31. AdManger.show_interstial();
  32. this.set_xxx();
  33. }
  34. /**
  35. * go to home page
  36. */
  37. btn_go_home() {
  38. this.close();
  39. director.loadScene("home");
  40. }
  41. /**
  42. * continue game
  43. */
  44. btn_continue_game() {
  45. this.close();
  46. }
  47. /**
  48. * restart game
  49. *
  50. */
  51. btn_restart_game() {
  52. this.close();
  53. Global.main_action.restart_game();
  54. }
  55. }