-
Notifications
You must be signed in to change notification settings - Fork 5
/
Win.js
62 lines (39 loc) · 1.57 KB
/
Win.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
BasicGame.MainMenu = function (game) {
this.bg;
this.title_image;
this.music = null;
this.playButton = null;
};
BasicGame.MainMenu.prototype = {
create: function () {
// add music
//this.music = this.add.audio('titleMusic');
//this.music.play();
this.bg = this.add.tileSprite(0, 0, this.game.width, this.game.height, 'starfield');
this.title_image = this.add.sprite(this.game.width/2, this.game.height/2, 'title_image');
this.title_image.anchor.set(0.5, 0.5);
this.title_image.scale.setTo(0.5, 0.5);
this.playButton = this.add.button((this.game.width/2), (this.game.height/2) + 100, 'button_normal', this.startGame, this, 'button_hover', 'button_normal', 'button_hover');
},
update: function () {
// Do some nice funky main menu effect here
},
resize: function (width, height) {
// If the game container is resized this function will be called automatically.
// You can use it to align sprites that should be fixed in place and other responsive display things.
this.bg.width = width;
this.bg.height = height;
//this.title_image.anchor.set(0.5, 0.5);
this.title_image.x = this.game.width/2;
this.title_image.y = this.game.height/2;
this.title_image.scale.setTo(0.5, 0.5);
this.playButton.x = this.game.width/2;
this.playButton.y = (this.game.height/2)+100;
},
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');
}
};