-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.js
More file actions
executable file
·46 lines (35 loc) · 1.31 KB
/
game.js
File metadata and controls
executable file
·46 lines (35 loc) · 1.31 KB
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
BasicGame.Game = function (game) {
};
BasicGame.Game.prototype = {
preload: function() {
this.load.image("sea", "assets/sea.png");
this.load.image("bullet", "assets/bullet.png");
this.load.spritesheet("greenEnemy", "assets/enemy.png", 32, 32);
},
create: function () {
this.sea = this.add.tileSprite(0, 0, 800, 600, 'sea');
this.enemy = this.add.sprite(400, 200, "greenEnemy");
this.enemy.anchor.setTo(0.5, 0.5);
this.physics.enable(this.enemy, Phaser.Physics.ARCADE)
this.enemy.animations.add("fly", [0, 1, 2], 20, true);
this.enemy.play("fly");
this.bullet = this.add.sprite(400, 300, "bullet");
this.bullet.anchor.setTo(0.5, 0.5);
this.physics.enable(this.bullet, Phaser.Physics.ARCADE);
this.bullet.body.velocity.y = -500;
},
update: function () {
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out!
this.sea.tilePosition.y += 0.2;
},
render: function(){
this.game.debug.body(this.bullet);
this.game.debug.body(this.enemy);
},
quitGame: function (pointer) {
// Here you should destroy anything you no longer need.
// Stop music, delete sprites, purge caches, free resources, all that good stuff.
// Then let's go back to the main menu.
this.state.start('MainMenu');
}
};