-
Notifications
You must be signed in to change notification settings - Fork 0
/
fast.html
74 lines (68 loc) · 2.37 KB
/
fast.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Whip-a-Wimp</title>
<meta name="viewport" content="width=320,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="yes"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
body { background: #000; }
body, canvas, div {
margin: 0;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
#Cocos2dGameContainer {
width: auto !important;
height: auto !important;
}
#gameCanvas {
display: block;
margin: 0 auto;
}
</style>
<script type="text/javascript" src="cocos2d-js-v3.5.js" charset="UTF-8"></script>
<script>
var resize = function () {
var canvas = document.getElementById('gameCanvas'),
ratioX = canvas.width / canvas.height,
width, height, marginTop;
if ((window.innerWidth / window.innerHeight) > ratioX) {
height = window.innerHeight;
width = height * ratioX;
marginTop = 0;
}
else {
var ratioY = 1 / ratioX;
width = window.innerWidth;
height = width * ratioY;
marginTop = (window.innerHeight - height) / 2;
}
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
canvas.style.marginTop = marginTop + 'px';
};
window.onload = function(event) {
cc.game.onStart = function () {
cc.view.adjustViewPort(true);
cc.LoaderScene.preload([g_resources], function () {
cc.director.runScene(new waw.TitleScene());
}, this);
};
cc.game.run("gameCanvas");
window.onresize = resize;
resize();
}
</script>
</head>
<body>
<canvas id="gameCanvas" width="320" height="240"></canvas>
</body>
</html>