-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.html
More file actions
35 lines (32 loc) · 885 Bytes
/
Copy pathtest.html
File metadata and controls
35 lines (32 loc) · 885 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<button onclick="createImg()">创建龙宝宝</button>
<div id="main">
</div>
</body>
<script type="text/javascript">
function dragon(imgSrc,x,y){
this.enemyNode = document.createElement("img");
this.enemyNode.src=imgSrc;
this.enemyNode.style.position = "absolute";
this.enemyNode.style.top = x+"px";
this.enemyNode.style.left = y+"px";
}
function createImg(){
var img = document.createElement("img");
img.src = "images/dragon/small/move.gif";
}
var main = document.getElementById("main");
var dragonSmall = new dragon("images/dragon/small/move.gif",100,300);
main.appendChild(dragonSmall.enemyNode);
var dragonBig = new dragon("images/dragon/big/move.gif",300,300);
main.appendChild(dragonBig.enemyNode);
document.body.onkeydown = function(){
}
</script>
</html>