main.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { _decorator, Component, game, Node} from 'cc';
  2. import { config } from './config';
  3. import { tools } from './tools';
  4. import { uiManager } from './manager/uiManager';
  5. import { home } from './ui/home/home';
  6. import { loading_view } from './ui/loading_view';
  7. import { SdkUtil } from './sdkUtil';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('main')
  10. export class main extends Component {
  11. @property(Node) home_node:Node = null;
  12. @property(Node) ui_parent = null;
  13. @property(Node) laoding_view_wait = null;
  14. @property(Node) send_msg_wait = null;
  15. private m_home_view:Node = null
  16. protected start(): void {
  17. game.frameRate = 61; //修复 iphone 15 抖动问题
  18. // PhysicsSystem2D.instance.fixedTimeStep = 1 / 60;
  19. SdkUtil.init()
  20. tools.init(this.node)
  21. this.home_node.removeAllChildren()
  22. uiManager.Instance().init(this.ui_parent,this.laoding_view_wait,this.send_msg_wait)
  23. this.preloadHomeView()
  24. this.showLoadingView()
  25. }
  26. private showLoadingView() {
  27. uiManager.Instance().showUi(config.UI.loading_view, this.node, (node:Node)=>{
  28. node.getComponent(loading_view).startLoading(()=>{
  29. this.showHomeView()
  30. })
  31. })
  32. }
  33. private preloadHomeView() {
  34. this.home_node.active = false
  35. uiManager.Instance().showUi(config.UI.home,this.home_node,(node:Node)=>{
  36. this.m_home_view = node
  37. })
  38. }
  39. private showHomeView() {
  40. this.home_node.active = true
  41. setTimeout(()=>{
  42. this.m_home_view.getComponent(home).init()
  43. },20)
  44. }
  45. }