
演示网站 HTML5 canvas会走乒乓球小游戏



编写代码
</style>
</head>
<body>
<div class="kbBox" id="kbBox"></div>
<div class="startGame" id="startGame">
<a href="javascript:void(0)" id="enterGame">进入游戏</a>
</div>
<div class="gameId" id="gameId" style="display: none;">
<canvas id="canvas"></canvas>
<p>游戏玩法:使用左键、右键和上箭头键移动。</p>
</div>
<script src="game.js"></script>
<script>
window.onload = function () {
var height = document.documentElement.clientHeight;
var kbBox = document.getElementById("kbBox");
var top = height - 400;
console.log(top);
kbBox.setAttribute("style","height:"+top/2+"px");
var startGameId = document.getElementById("startGame");
var enterGameId = document.getElementById("enterGame");
var gameId = document.getElementById("gameId");
enterGameId.onclick = function () {
gameId.setAttribute("style","display:block");
startGameId.setAttribute("style","display:none");
Loop();
}
}
</script>
</body>
</html>
注册免费下载
抱歉,隐藏内容须成功 评论本文 后刷新可见!
