index.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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-multi-fingered="2"
  32. data-show-fps="true" data-show-log="false"
  33. data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
  34. </div>
  35. <script>
  36. var loadScript = function (list, callback) {
  37. var loaded = 0;
  38. var loadNext = function () {
  39. loadSingleScript(list[loaded], function () {
  40. loaded++;
  41. if (loaded >= list.length) {
  42. callback();
  43. }
  44. else {
  45. loadNext();
  46. }
  47. })
  48. };
  49. loadNext();
  50. };
  51. var loadSingleScript = function (src, callback) {
  52. var s = document.createElement('script');
  53. s.async = false;
  54. s.src = src;
  55. s.addEventListener('load', function () {
  56. s.parentNode.removeChild(s);
  57. s.removeEventListener('load', arguments.callee, false);
  58. callback();
  59. }, false);
  60. document.body.appendChild(s);
  61. };
  62. var xhr = new XMLHttpRequest();
  63. xhr.open('GET', './manifest.json?v=' + Math.random(), true);
  64. xhr.addEventListener("load", function () {
  65. var manifest = JSON.parse(xhr.response);
  66. var list = manifest.initial.concat(manifest.game);
  67. loadScript(list, function () {
  68. /**
  69. * {
  70. * "renderMode":, //Engine rendering mode, "canvas" or "webgl"
  71. * "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
  72. * "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
  73. * "calculateCanvasScaleFactor": //a function return canvas scale factor
  74. * }
  75. **/
  76. egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
  77. var backingStore = context.backingStorePixelRatio ||
  78. context.webkitBackingStorePixelRatio ||
  79. context.mozBackingStorePixelRatio ||
  80. context.msBackingStorePixelRatio ||
  81. context.oBackingStorePixelRatio ||
  82. context.backingStorePixelRatio || 1;
  83. return (window.devicePixelRatio || 1) / backingStore;
  84. }});
  85. });
  86. });
  87. xhr.send(null);
  88. </script>
  89. </body>
  90. </html>