index.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Cocos Creator | zhetian</title>
  6. <!--http://www.html5rocks.com/en/mobile/mobifying/-->
  7. <meta name="viewport"
  8. content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1" />
  9. <!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
  10. <meta name="mobile-web-app-capable" content="yes">
  11. <meta name="apple-mobile-web-app-capable" content="yes">
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  13. <meta name="format-detection" content="telephone=no">
  14. <!-- force webkit on 360 -->
  15. <meta name="renderer" content="webkit" />
  16. <meta name="force-rendering" content="webkit" />
  17. <!-- force edge on IE -->
  18. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  19. <meta name="msapplication-tap-highlight" content="no">
  20. <!-- force full screen on some browser -->
  21. <meta name="full-screen" content="yes" />
  22. <meta name="x5-fullscreen" content="true" />
  23. <meta name="360-fullscreen" content="true" />
  24. <!-- force screen orientation on some browser -->
  25. <meta name="screen-orientation" content="portrait" />
  26. <meta name="x5-orientation" content="portrait">
  27. <!--fix fireball/issues/3568 -->
  28. <!--<meta name="browsermode" content="application">-->
  29. <meta name="x5-page-mode" content="app">
  30. <!--<link rel="apple-touch-icon" href=".png" />-->
  31. <!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
  32. <script type="text/javascript">
  33. var sUserAgent = navigator.userAgent.toLowerCase();
  34. var link = document.createElement('link');
  35. link.type = 'text/css';
  36. link.rel = 'stylesheet';
  37. if (/ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(sUserAgent)) {
  38. //移动端
  39. console.log("移动端")
  40. link.href = 'style-mobile.css';
  41. document.getElementsByTagName('head')[0].appendChild(link);
  42. } else {
  43. //pc端  
  44. console.log("pc端")
  45. link.href = 'style-desktop.css';
  46. document.getElementsByTagName('head')[0].appendChild(link);
  47. }
  48. </script>
  49. <link rel="icon" href="favicon.ico" />
  50. </head>
  51. <body>
  52. <style type="text/css">
  53. html {
  54. overflow-x: hidden;
  55. overflow-y: hidden;
  56. }
  57. /* 将背景图片应用到整个页面 */
  58. body {
  59. background-image: url('background.d7add.jpg');
  60. background-size: cover;
  61. background-position: center;
  62. background-repeat: no-repeat;
  63. margin: 0;
  64. padding: 0;
  65. height: 100vh;
  66. width: 100vw;
  67. }
  68. /* 移除GameDiv的背景图片 */
  69. #GameDiv {
  70. position: relative;
  71. }
  72. /* 确保画布在背景上方 */
  73. /* #GameCanvas {
  74. position: relative;
  75. z-index: 1;
  76. } */
  77. </style>
  78. <div id="GameDiv">
  79. <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
  80. <div id="splash">
  81. <div class="progress-bar stripes">
  82. <span style="width: 0%"></span>
  83. </div>
  84. </div>
  85. </div>
  86. <script src="src/settings.js" charset="utf-8"></script>
  87. <script src="https://sdkapi.happilygame.com/static/lib/pp/libQuickSDK_v2.js"></script>
  88. <script src="main.js" charset="utf-8"></script>
  89. <!-- 开启vConsole -->
  90. <!-- <script src="vconsole.min.js"></script> -->
  91. <script type="text/javascript">
  92. (function () {
  93. // open web debugger console
  94. if (typeof VConsole !== 'undefined') {
  95. window.vConsole = new VConsole();
  96. }
  97. var height = document.documentElement.clientHeight;
  98. var width = document.documentElement.clientWidth;
  99. var fixWidth = height / 1334 * 750;
  100. var gameDiv = document.getElementById('GameDiv');
  101. gameDiv.style.height = `${height}px`;
  102. if (fixWidth > width) {
  103. gameDiv.style.width = `${width}px`;
  104. } else {
  105. gameDiv.style.width = `${fixWidth}px`;
  106. }
  107. var debug = window._CCSettings.debug;
  108. var splash = document.getElementById('splash');
  109. splash.style.display = 'block';
  110. function loadScript(moduleName, cb) {
  111. function scriptLoaded() {
  112. document.body.removeChild(domScript);
  113. domScript.removeEventListener('load', scriptLoaded, false);
  114. cb && cb();
  115. };
  116. var domScript = document.createElement('script');
  117. domScript.async = true;
  118. domScript.src = moduleName;
  119. domScript.addEventListener('load', scriptLoaded, false);
  120. document.body.appendChild(domScript);
  121. }
  122. loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.js', function () {
  123. if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
  124. loadScript(debug ? 'physics.js' : 'physics-min.js', window.boot);
  125. }
  126. else {
  127. window.boot();
  128. }
  129. });
  130. })();
  131. </script>
  132. </body>
  133. </html>