-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
50 lines (38 loc) · 1.56 KB
/
start.js
File metadata and controls
50 lines (38 loc) · 1.56 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
47
48
49
50
var startState = {
preload: function() {
game.load.image('bg', 'assets/start.jpg');
game.load.spritesheet('play_bt', 'assets/playbutton.png', 249, 83);
game.load.spritesheet('setting_bt', 'assets/settingbutton.png', 250, 100);
game.load.spritesheet('credict_bt', 'assets/credictbutton.png', 250, 85);
game.load.audio('button_sound', 'assets/button.wav');
},
create: function() {
game.add.image(0,0,'bg');
this.play_bt = game.add.button(game.world.centerX - 295, 100, 'play_bt', this.playClick, this, 1, 0, 0);
this.setting_bt = game.add.button(game.world.centerX - 295, 170, 'setting_bt', this.settingClick, this, 1, 0, 0);
this.credict_bt = game.add.button(game.world.centerX - 295, 270, 'credict_bt', this.credictClick, this, 1, 0, 0);
this.play_bt.onInputOver.add(this.buttonOver,this);
this.setting_bt.onInputOver.add(this.buttonOver,this);
this.credict_bt.onInputOver.add(this.buttonOver,this);
},
buttonOver:function(){
this.buttonSound=game.add.audio('button_sound');
if(soundmute==0)
this.buttonSound.play();
},
playClick:function(){
score=0;
outcome=0;
game.state.start('level1');
},
settingClick:function(){
game.state.start('setting');
},
credictClick:function(){
},
update: function() {
if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) ) {
this.playClick();
}
}
};