拿到了这个源代码,但一直无法成功运行,求指教:
页面代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>飞机大战</title>
</head>
<body>
<div id="stage" style="margin: 0 auto; width: 480px; height: 650px; text-align: center; vertical-align: middle" >
<canvas id="canvas" style="border:2px solid red;" width="480" height="650">
不支持画板对象
</canvas>
</div>
<script type = "text/javascript" src = "tools.js"> </script>
<script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var enemy = new Image();
enemy.src = "images/enemy.png";
var enemy2 = new Image();
enemy2.src = "images/enemy2.png";
var enemy3 = new Image();
enemy3.src = "images/enemy3.png";
var bg = new Image();
bg.src = "images/bg.png";
enemy.onload = function() {
}
</script>
</body>
</html>
页面代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>飞机大战</title>
</head>
<body>
<div id="stage" style="margin: 0 auto; width: 480px; height: 650px; text-align: center; vertical-align: middle" >
<canvas id="canvas" style="border:2px solid red;" width="480" height="650">
不支持画板对象
</canvas>
</div>
<script type = "text/javascript" src = "tools.js"> </script>
<script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var enemy = new Image();
enemy.src = "images/enemy.png";
var enemy2 = new Image();
enemy2.src = "images/enemy2.png";
var enemy3 = new Image();
enemy3.src = "images/enemy3.png";
var bg = new Image();
bg.src = "images/bg.png";
enemy.onload = function() {
}
</script>
</body>
</html>