HomeUI.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const {ccclass, property} = cc._decorator;
  2. import PrefabUtil from '../utils/manager/PrefabUtil';
  3. import UIbase from '../utils/UIbase';
  4. import GameUI from './GameUI';
  5. import Plat from '../utils/Palt';
  6. import SettingUI from './SettingUI';
  7. import ShopUI from './ShopUI';
  8. import rankUI from './rankUI';
  9. import AudioMgr from '../manager/AudioMgr';
  10. import AudioPath from '../datas/AudioPath';
  11. @ccclass
  12. export default class HomeUI extends UIbase {
  13. private static _inst:HomeUI;
  14. public static get inst()
  15. {
  16. if(this._inst==null)
  17. {
  18. let v=cc.instantiate(PrefabUtil.get("HomeUI"));
  19. this._inst=v.getComponent(HomeUI);
  20. }
  21. return this._inst;
  22. }
  23. protected onShow(): void {
  24. Plat.showInterstitialAd();
  25. Plat.showBanner();
  26. AudioMgr.playBgm();
  27. }
  28. protected onHide(): void {
  29. Plat.hideBanner()
  30. }
  31. public onClickStartGame()
  32. {
  33. this.hideUI();
  34. GameUI.inst.onStartGame();
  35. AudioMgr.playSound(AudioPath.CLICK);
  36. }
  37. public onClickShare()
  38. {
  39. Plat.shareAppMessage();
  40. AudioMgr.playSound(AudioPath.CLICK);
  41. }
  42. public onClickRank()
  43. {
  44. rankUI.inst.showUI();
  45. AudioMgr.playSound(AudioPath.CLICK);
  46. }
  47. public onClickSettingBtn()
  48. {
  49. SettingUI.inst.showUI();
  50. AudioMgr.playSound(AudioPath.CLICK);
  51. }
  52. onClickShop(){
  53. ShopUI.inst.showUI();
  54. AudioMgr.playSound(AudioPath.CLICK);
  55. }
  56. public onJump(event,appid)
  57. {
  58. if(Plat.pt.navigateToMiniProgram!=null)
  59. {
  60. Plat.pt.navigateToMiniProgram({
  61. "appId":appid
  62. });
  63. }
  64. }
  65. }