-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsceneMenu.js
57 lines (41 loc) · 1.35 KB
/
sceneMenu.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
import { sceneGame, game } from "./sceneGame.js";
export const sceneMenu = new Phaser.Scene('sceneMenu');
sceneMenu.preload = function () {
}
sceneMenu.create = function () {
const esc = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ESC);
esc.on('down', () => sceneMenu.toggle());
sceneMenu.visible = false;
}
sceneMenu.show = function () {
sceneGame.pause();
this.r = this.add.rectangle(320, 240, 600, 450, 0x222288);
this.menuText = this.add.text(100, 50, "[Inventaire]",
{ color: "white", fontFamily: 'Arial', fontSize: '24px', wordWrap: { width: 400, useAdvancedWrap: true } });
let iy = 0;
this.objText = [];
for (const key in game.state)
if (key.startsWith("obj")) {
this.objText.push(this.add.text(100, 50 + 40 + iy * 32, ". " + key.slice(3),
{ color: "white", fontFamily: 'Arial', fontSize: '18px', wordWrap: { width: 400, useAdvancedWrap: true } }));
iy += 1;
}
}
sceneMenu.hide = function() {
sceneGame.resume();
this.r.destroy();
this.menuText.destroy();
this.objText.map((o) => o.destroy());
}
sceneMenu.toggle = function () {
//sceneMenu.
if (!sceneMenu.visible) {
sceneMenu.show();
}
else {
sceneMenu.hide();
}
sceneMenu.visible = !sceneMenu.visible;
}
sceneMenu.update = function () {
}