-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (41 loc) · 1.34 KB
/
index.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
<html>
<head>
<title>Clrfeed-ex01</title>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/phaser/2.2.2/phaser.min.js"></script>
<script>
var game = new Phaser.Game(500, 50, Phaser.AUTO, 'game');
var play = function(game){} ; // Constructor
play.prototype = {
preload:function(){
this.load.baseURL = 'http://files.phaser.io.s3.amazonaws.com/codingtips/issue001/';
this.load.crossOrigin = 'anonymous';
this.load.image('bg', 'assets/background.png');
this.load.image('tank', 'assets/tank.png');
// Note: Graphics from Amiga Tanx Copyright 1991 Gary Roberts
game.world.setBounds(0,0,1000,1000);
},
create:function(){
this.game.add.sprite(0,0,'bg');
tank = this.game.add.sprite(0,0,'tank');
this.game.camera.follow(tank);
},
update:function(){
if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
tank.x += 10;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
tank.x -= 10;
}
}
};
game.state.add("L0",play);
game.state.start("L0");
</script>
</head>
<body>
<div id="game"></div>
</body>
</html>