XGame.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * 全局导入
  3. * 全局配置
  4. * 工具
  5. */
  6. import * as Context from "./core/Context";
  7. import * as define from "./data/Define";
  8. import * as tools from "./utils/Utils";
  9. import { HttpMgr } from "./core/mgrs/HttpMgr";
  10. import Common from "./utils/Common";
  11. import UIMgr from "./fgui/core/UIMgr";
  12. import { SoundMgr } from "./core/mgrs/SoundMgr";
  13. import { ResMgr } from "./core/mgrs/ResMgr";
  14. import { eventMgr } from "./core/mgrs/EventMgr";
  15. import { ConfigMgr } from "./core/mgrs/ConfigMgr";
  16. import PoolD3Mgr from "./core/mgrs/PoolD3Mgr";
  17. import UIMsg from "./ui/UIMsg";
  18. let context = Context.context;
  19. let uiMgr = UIMgr.inst;
  20. let soundMgr = SoundMgr.getInstance();
  21. let resMgr = ResMgr.getInstance();
  22. let httpMgr = HttpMgr.getInstance();
  23. let common = Common.getInstance();
  24. let cfgMgr = ConfigMgr.getInstance();
  25. let poolD3Mgr = PoolD3Mgr.ins;
  26. let d3TexUrl = "res/d3Res/";
  27. let d3ModeUrl = "res/unityRes/";
  28. /**
  29. * 适配舞台
  30. */
  31. function setStageSize(view: any) {
  32. if (view.width) {
  33. view.width = Laya.stage.width;
  34. view.height = Laya.stage.height;
  35. }
  36. }
  37. /**
  38. * 适配舞台背景
  39. */
  40. function filledBg(view: any) {
  41. let wh = Laya.stage.height / Laya.stage.width;
  42. if (wh > 16 / 9) {
  43. view.height = Laya.stage.height;
  44. view.width = Laya.stage.height / 1334 * 750;
  45. }
  46. else {
  47. view.width = Laya.stage.width;
  48. view.height = Laya.stage.width / 750 * 1334;
  49. }
  50. }
  51. /**
  52. * 适配刘海
  53. */
  54. function setNotch(view: any) {
  55. if (view.height) {
  56. view.y += context.notchHeight;
  57. }
  58. }
  59. function showTip(str: string) {
  60. uiMgr.Show(UIMsg, str);
  61. }
  62. function log(...args) {
  63. console.log(args);
  64. }
  65. export {
  66. define,
  67. }
  68. export let xGame = {
  69. context,
  70. eventMgr,
  71. resMgr,
  72. uiMgr,
  73. soundMgr,
  74. define,
  75. tools,
  76. httpMgr,
  77. d3TexUrl,
  78. d3ModeUrl,
  79. common,
  80. cfgMgr,
  81. poolD3Mgr,
  82. setStageSize,
  83. filledBg,
  84. setNotch,
  85. showTip,
  86. log,
  87. }
  88. window["xGame"] = xGame;