game.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. console.log("yes i am in")
  2. loadCC();
  3. const res = tt.canIUse("getLiveUserInfo");
  4. console.log("Version: "+ tt.env.VERSION);
  5. console.log("DataPath: "+ tt.env.USER_DATA_PATH);
  6. tt.onShow((res) => {
  7. console.log("i'm show")
  8. });
  9. tt.onError((err) => {
  10. console.log(err);
  11. });
  12. //const res = tt.getLaunchOptionsSync();
  13. //console.log(res.path)
  14. /*tt.getExtConfig({
  15. success: (res) => {
  16. console.log("success: "+ res.openScene)
  17. },
  18. fail: (res) => {
  19. console.log("failed");
  20. },
  21. });*/
  22. function loadCC() {
  23. require('./web-adapter');
  24. // Polyfills bundle.
  25. require("src/polyfills.bundle.43263.js");
  26. // SystemJS support.
  27. require("src/system.bundle.dfb8d.js");
  28. // Adapt for IOS, swap if opposite
  29. if (canvas){
  30. var _w = canvas.width;
  31. var _h = canvas.height;
  32. if (screen.width < screen.height) {
  33. if (canvas.width > canvas.height) {
  34. _w = canvas.height;
  35. _h = canvas.width;
  36. }
  37. } else {
  38. if (canvas.width < canvas.height) {
  39. _w = canvas.height;
  40. _h = canvas.width;
  41. }
  42. }
  43. canvas.width = _w;
  44. canvas.height = _h;
  45. }
  46. // Adjust initial canvas size
  47. if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}
  48. const importMap = require("src/import-map.ac3d3.js").default;
  49. System.warmup({
  50. importMap,
  51. importMapUrl: 'src/import-map.ac3d3.js',
  52. defaultHandler: (urlNoSchema) => {
  53. require('.' + urlNoSchema);
  54. },
  55. handlers: {
  56. 'plugin:': (urlNoSchema) => {
  57. requirePlugin(urlNoSchema);
  58. },
  59. },
  60. });
  61. System.import('./application.25127.js').then(({ Application }) => {
  62. return new Application();
  63. }).then((application) => {
  64. return onApplicationCreated(application);
  65. }).catch((err) => {
  66. console.error(err);
  67. });
  68. function onApplicationCreated(application) {
  69. return System.import('cc').then((cc) => {
  70. require('./engine-adapter');
  71. return application.init(cc);
  72. }).then(() => { return application.start(); });
  73. }
  74. }