-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmainMenu.js
45 lines (28 loc) · 1.47 KB
/
mainMenu.js
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
BasicGame.MainMenu = function (game) {
this.music = null;
this.playButton = null;
};
BasicGame.MainMenu.prototype = {
create: function () {
// We've already preloaded our assets, so let's kick right into the Main Menu itself.
// Here all we're doing is playing some music and adding a picture and button
// Naturally I expect you to do something significantly better :)
this.add.sprite(0, 0, 'titlepage');
this.loadingText = this.add.text(this.game.width / 2, this.game.height / 2 + 80, "Press Z or tap/click game to start", { font: "20px monospace", fill: "#fff" });
this.loadingText.anchor.setTo(0.5, 0.5);
this.add.text(this.game.width / 2, this.game.height - 90, "image assets Copyright (c) 2002 Ari Feldman", { font: "12px monospace", fill: "#fff", align: "center"}).anchor.setTo(0.5, 0.5);
this.add.text(this.game.width / 2, this.game.height - 75, "sound assets Copyright (c) 2012 - 2013 Devin Watson", { font: "12px monospace", fill: "#fff", align: "center"}).anchor.setTo(0.5, 0.5);
},
update: function () {
if (this.input.keyboard.isDown(Phaser.Keyboard.Z) || this.input.activePointer.isDown) {
this.startGame();
}
// Do some nice funky main menu effect here
},
startGame: function (pointer) {
// Ok, the Play Button has been clicked or touched, so let's stop the music (otherwise it'll carry on playing)
// this.music.stop();
// And start the actual game
this.state.start('Game');
}
};