index.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Egret</title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
  7. <meta name="apple-mobile-web-app-capable" content="yes" />
  8. <meta name="full-screen" content="true" />
  9. <meta name="screen-orientation" content="portrait" />
  10. <meta name="x5-fullscreen" content="true" />
  11. <meta name="360-fullscreen" content="true" />
  12. <style>
  13. html, body {
  14. -ms-touch-action: none;
  15. background: #888888;
  16. padding: 0;
  17. border: 0;
  18. margin: 0;
  19. height: 100%;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
  25. data-entry-class="Main"
  26. data-orientation="auto"
  27. data-scale-mode="showAll"
  28. data-frame-rate="60"
  29. data-content-width="988"
  30. data-content-height="718"
  31. data-show-paint-rect="false"
  32. data-multi-fingered="2"
  33. data-show-fps="false" data-show-log="false"
  34. data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
  35. </div>
  36. <script>
  37. var loadScript = function (list, callback) {
  38. var loaded = 0;
  39. var loadNext = function () {
  40. loadSingleScript(list[loaded], function () {
  41. loaded++;
  42. if (loaded >= list.length) {
  43. callback();
  44. }
  45. else {
  46. loadNext();
  47. }
  48. })
  49. };
  50. loadNext();
  51. };
  52. var loadSingleScript = function (src, callback) {
  53. var s = document.createElement('script');
  54. s.async = false;
  55. s.src = src;
  56. s.addEventListener('load', function () {
  57. s.parentNode.removeChild(s);
  58. s.removeEventListener('load', arguments.callee, false);
  59. callback();
  60. }, false);
  61. document.body.appendChild(s);
  62. };
  63. var xhr = new XMLHttpRequest();
  64. xhr.open('GET', './manifest.json?v=' + Math.random(), true);
  65. xhr.addEventListener("load", function () {
  66. var manifest = JSON.parse(xhr.response);
  67. var list = manifest.initial.concat(manifest.game);
  68. loadScript(list, function () {
  69. /**
  70. * {
  71. * "renderMode":, //Engine rendering mode, "canvas" or "webgl"
  72. * "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
  73. * "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
  74. * "calculateCanvasScaleFactor": //a function return canvas scale factor
  75. * }
  76. **/
  77. egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
  78. var backingStore = context.backingStorePixelRatio ||
  79. context.webkitBackingStorePixelRatio ||
  80. context.mozBackingStorePixelRatio ||
  81. context.msBackingStorePixelRatio ||
  82. context.oBackingStorePixelRatio ||
  83. context.backingStorePixelRatio || 1;
  84. return (window.devicePixelRatio || 1) / backingStore;
  85. }});
  86. });
  87. });
  88. xhr.send(null);
  89. </script>
  90. </body>
  91. </html>