-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.js
133 lines (106 loc) · 4.26 KB
/
Menu.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
var textHeader;
var textOption1;
var textOption2;
var textOption3;
var textOption4;
var textOption5;
var modeOption = 1;
var globalDasSpeed = 1;
class Menu extends Phaser.Scene {
constructor() {
super({key:"Menu"});
}
init() {
}
update(delta) {
this.draw();
}
preload() {
this.load.image('back', 'assets/background/1.png');
}
create() {
this.add.image(400,300,'back');
textHeader = this.add.text(20,20,"Select a Mode | Press X to Play", {font:"30px Arial", stroke:"#000000", strokeThickness:6, fill:"#FF88FF"});
textOption1 = this.add.text(20,60," Marathon", {font:"30px Arial", stroke:"#000000", strokeThickness:6, fill:"#FFFFFF"});
textOption2 = this.add.text(20,100," Sprint", {font:"30px Arial", stroke:"#000000", strokeThickness:6, fill:"#FFFFFF"});
textOption3 = this.add.text(20,140," Ultra", {font:"30px Arial", stroke:"#000000", strokeThickness:6, fill:"#FFFFFF"});
textOption4 = this.add.text(20,180," Master", {font:"30px Arial", stroke:"#000000", strokeThickness:6, fill:"#FFFFFF"});
textOption5 = this.add.text(20,220," Ultimate", {font:"30px Arial", stroke:"#000000", strokeThickness:6, fill:"#FFFFFF"});
this.key_X = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.X);
this.key_UP = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP);
this.key_DOWN = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN);
this.input.keyboard.on('keydown_X', (event) => {
switch(modeOption) {
case 1:
this.scene.restart("Marathon");
this.scene.start("Marathon");
break;
case 2:
this.scene.restart("Sprint");
this.scene.start("Sprint");
break;
case 3:
this.scene.restart("Ultra");
this.scene.start("Ultra");
break;
case 4:
this.scene.restart("Master");
this.scene.start("Master");
break;
case 5:
this.scene.restart("Ultimate");
this.scene.start("Ultimate");
break;
}
})
this.input.keyboard.on('keydown_UP', (event) => {
if(modeOption > 1) {
modeOption--;
}
})
this.input.keyboard.on('keydown_DOWN', (event) => {
if(modeOption < 5) {
modeOption++;
}
})
}
draw() {
switch(modeOption) {
case 1:
textOption1.setText("Marathon <---");
textOption2.setText("Sprint");
textOption3.setText("Ultra");
textOption4.setText("Master");
textOption5.setText("Ultimate");
break;
case 2:
textOption1.setText("Marathon");
textOption2.setText("Sprint <---");
textOption3.setText("Ultra");
textOption4.setText("Master");
textOption5.setText("Ultimate");
break;
case 3:
textOption1.setText("Marathon");
textOption2.setText("Sprint");
textOption3.setText("Ultra <---");
textOption4.setText("Master");
textOption5.setText("Ultimate");
break;
case 4:
textOption1.setText("Marathon");
textOption2.setText("Sprint");
textOption3.setText("Ultra");
textOption4.setText("Master <---");
textOption5.setText("Ultimate");
break;
case 5:
textOption1.setText("Marathon");
textOption2.setText("Sprint");
textOption3.setText("Ultra");
textOption4.setText("Master");
textOption5.setText("Ultimate <---");
break;
}
}
}