Loading.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import Tools from "../Common/Tools";
  2. import JiuWuSDK from "../SDK/JiuWuSDK";
  3. import CacheMgr from "../Common/manage/CacheMgr";
  4. import Global from "../Common/Global";
  5. import Emit from "../Common/manage/Emit/Emit";
  6. import LogMgr from "../Common/LogMgr";
  7. import QgBanner from "../Common/manage/Api/QgBanner";
  8. import EmitData from "../Common/manage/Emit/EmitData";
  9. const {ccclass, property} = cc._decorator;
  10. @ccclass
  11. export default class Loading extends cc.Component {
  12. @property(cc.Node)
  13. round: cc.Node = null;
  14. @property(cc.Node)
  15. mask: cc.Node = null;
  16. private tween = null;
  17. protected onLoad() {
  18. console.log('zh: Loading onLoad')
  19. // @ts-ignore
  20. if (window.qg) {
  21. Global.isVivo = true;
  22. }
  23. this.mask.width = 0
  24. //假的进度条
  25. this.tween = cc.tween(this.mask)
  26. .to(3, {width: 300}, {easing: "quadOut"})
  27. .start();
  28. let i = 0;
  29. cc.director.preloadScene("Game")
  30. let num = Tools.model_initModel(() => {
  31. i++
  32. if (i === num) {
  33. this.tween.stop();
  34. cc.tween(this.mask)
  35. .to(2, {width: 500}, {easing: 'quadOut'})
  36. .call(() => {
  37. if (Global.isVivo) {
  38. if (JiuWuSDK.initSDK) {
  39. this.loadScene();
  40. } else {
  41. Emit.instance().on(EmitData.LOAD_GAME_SCENE, this.loadScene, this);
  42. }
  43. } else {
  44. cc.director.loadScene('Game');
  45. }
  46. })
  47. .start();
  48. }
  49. });
  50. this.someMotor();
  51. console.log('zh: Loading onLoad end ')
  52. }
  53. loadScene() {
  54. cc.director.loadScene('Game');
  55. }
  56. someMotor() {
  57. if (!Global.isVivo) {
  58. return
  59. }
  60. // @ts-ignore
  61. window.qg.onShow(() => {
  62. LogMgr.log('Banner刷新>>>>>>onShow', QgBanner.isShow);
  63. if (QgBanner.isShow) {
  64. QgBanner.cutBanner().then();
  65. }
  66. cc.audioEngine.resumeMusic()
  67. })
  68. // @ts-ignore
  69. window.qg.onHide(() => {
  70. CacheMgr.updateData();
  71. cc.audioEngine.pauseMusic()
  72. })
  73. JiuWuSDK.inSet_API_Config().then(() => {
  74. Emit.instance().emit(EmitData.LOAD_GAME_SCENE);
  75. })
  76. }
  77. }