-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMainMenu.js
137 lines (97 loc) · 3.73 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
BasicGame.MainMenu = function (game) {
this.music = null;
this.playButton = null;
};
BasicGame.MainMenu.prototype = {
create: function () {
this.music = this.add.audio('music',1,true);
if(playmusic==true){
this.music.play('',0,1,true);
}
score = 0;
clicks = 0;
this.titleimage = this.add.sprite(this.world.centerX,150, 'title');
this.titleimage.anchor.setTo(0.5,0.5);
this.titleimage.scale.setTo(0.5,0.5);
this.playButton = this.add.button(this.world.centerX, this.world.height - 150, 'play', this.startGame, this, 1,0,2);
this.playButton.scale.setTo(0.5,0.5);
this.playButton.anchor.setTo(0.5,0.5);
this.musicButton = this.add.button(this.world.centerX, this.world.height - 10, 'musicbutton', this.changemusic, this, 1,0,2);
this.musicButton.scale.setTo(0.5,0.5);
this.musicButton.anchor.setTo(0.5,1);
this.shapes1 = this.add.sprite(this.world.centerX,this.world.centerY+10,'spriteset');
this.shapes1.frameName = 'shape1.png';
this.shapes1.anchor.setTo(0.5,0.5);
this.shapes1.alpha = 0;
// this.shapes2 = this.add.sprite(this.world.centerX+80,this.world.centerY+10,'spriteset');
// this.shapes2.frameName = 'shape2.png';
// this.shapes2.anchor.setTo(0.5,0.5);
this.frameNo = 1;
this.shapetween = this.add.tween(this.shapes1).to({ alpha: 1 }, 2000, Phaser.Easing.Sinusoidal.InOut, true, 0, 1000, true);
// this.frameSwitch = this.time.events.loop(150, this.updateFrame, this);
},
changemusic : function(){
if(playmusic==true){
this.music.stop();
playmusic = false;
}
else{
this.music.play();
playmusic = true;
}
},
updateFrame : function(){
this.frameNo = this.rnd.integerInRange(1,6);
this.shapes1.frameName = 'shape'+this.frameNo+'.png';
// this.frameNo = this.rnd.integerInRange(1,6);
// this.shapes2.frameName = 'shape'+this.frameNo+'.png';
},
update: function () {
if(this.shapes1.alpha==0){
this.updateFrame();
}
// this.shapes1.angle++; // Do some nice funky main menu effect here
},
startGame: function (pointer) {
this.music.stop();
this.state.start('Game');
}
};
BasicGame.EndScreen = function (game) {
};
BasicGame.EndScreen.prototype = {
create: function () {
this.music = this.add.audio('music',1,true);
if(playmusic==true){
this.music.play('',0,1,true);
}
this.scoretext = this.add.bitmapText(this.world.centerX,40,'font','Y O U T O O K',30);
this.scoretext.x = this.world.centerX - this.scoretext.textWidth/2;
this.timetext = this.add.bitmapText(this.world.centerX,100,'font',score+' S E C O N D S',30);
this.timetext.x = this.world.centerX - this.timetext.textWidth/2;
this.clicktext = this.add.bitmapText(this.world.centerX,160,'font','A N D C L I C K E D',30);
this.clicktext.x = this.world.centerX - this.clicktext.textWidth/2;
this.totalclickstext = this.add.bitmapText(this.world.centerX,220,'font',clicks+' T I M E S',30);
this.totalclickstext.x = this.world.centerX - this.totalclickstext.textWidth/2;
this.backButton = this.add.button(10, this.world.height - 5, 'back', this.startGame, this, 1,0,2);
this.backButton.scale.setTo(0.4,0.4);
this.backButton.anchor.setTo(0,1);
this.musicButton = this.add.button(this.world.width-10, this.world.height - 5, 'musicbutton', this.changemusic, this, 1,0,2);
this.musicButton.scale.setTo(0.4,0.4);
this.musicButton.anchor.setTo(1,1);
},
changemusic : function(){
if(playmusic==true){
this.music.stop();
playmusic = false;
}
else{
this.music.play();
playmusic = true;
}
},
startGame: function (pointer) {
this.music.stop();
this.state.start('MainMenu');
}
}