Loading.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. // @ts-ignore
  19. if (window.qg) {
  20. Global.isVivo = true;
  21. }
  22. this.mask.width = 0
  23. //假的进度条
  24. this.tween = cc.tween(this.mask)
  25. .to(3, {width: 300}, {easing: "quadOut"})
  26. .start();
  27. let i = 0;
  28. cc.director.preloadScene("Game")
  29. let num = Tools.model_initModel(() => {
  30. i++
  31. if (i === num) {
  32. this.tween.stop();
  33. cc.tween(this.mask)
  34. .to(2, {width: 500}, {easing: 'quadOut'})
  35. .call(() => {
  36. if (Global.isVivo) {
  37. if (JiuWuSDK.initSDK) {
  38. this.loadScene();
  39. } else {
  40. Emit.instance().on(EmitData.LOAD_GAME_SCENE, this.loadScene, this);
  41. }
  42. } else {
  43. cc.director.loadScene('Game');
  44. }
  45. })
  46. .start();
  47. }
  48. });
  49. this.someMotor();
  50. }
  51. loadScene() {
  52. cc.director.loadScene('Game');
  53. }
  54. someMotor() {
  55. if (!Global.isVivo) {
  56. return
  57. }
  58. // @ts-ignore
  59. window.qg.onShow(() => {
  60. LogMgr.log('Banner刷新>>>>>>onShow', QgBanner.isShow);
  61. if (QgBanner.isShow) {
  62. QgBanner.cutBanner().then();
  63. }
  64. cc.audioEngine.resumeMusic()
  65. })
  66. // @ts-ignore
  67. window.qg.onHide(() => {
  68. CacheMgr.updateData();
  69. cc.audioEngine.pauseMusic()
  70. })
  71. JiuWuSDK.inSet_API_Config().then(() => {
  72. Emit.instance().emit(EmitData.LOAD_GAME_SCENE);
  73. })
  74. }
  75. }