-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSceneSelector.ts
More file actions
62 lines (51 loc) · 1.79 KB
/
SceneSelector.ts
File metadata and controls
62 lines (51 loc) · 1.79 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
51
52
53
54
55
56
57
58
59
60
61
62
import Phaser from "phaser";
export class SceneSelector extends Phaser.Scene {
parts = {
'1': "Basic Player Movement",
'2': "Interpolation",
'3': "Client-predicted Input",
'4': "Fixed Tickrate",
};
constructor() {
super({ key: "selector", active: true });
}
preload() {
// update menu background color
this.cameras.main.setBackgroundColor(0x000000);
// preload demo assets
// this.load.image('ship_0001', 'assets/ship_0001.png');
this.load.image('ship_0001', 'https://cdn.glitch.global/3e033dcd-d5be-4db4-99e8-086ae90969ec/ship_0001.png?v=1649945243288');
this.cameras.main.setBackgroundColor(0x000000);
this.load.spritesheet("pj", "./pj/4500.png", {
frameWidth: 140,
frameHeight: 170,
});
}
create() {
// automatically navigate to hash scene if provided
if (window.location.hash) {
this.runScene(window.location.hash.substring(1));
return;
}
const textStyle: Phaser.Types.GameObjects.Text.TextStyle = {
color: "#ff0000",
fontSize: "32px",
// fontSize: "24px",
fontFamily: "Arial"
};
for (let partNum in this.parts) {
const index = parseInt(partNum) - 1;
const label = this.parts[partNum];
// this.add.text(32, 32 + 32 * index, `Part ${partNum}: ${label}`, textStyle)
this.add.text(130, 150 + 70 * index, `Part ${partNum}: ${label}`, textStyle)
.setInteractive()
.setPadding(6)
.on("pointerdown", () => {
this.runScene(`part${partNum}`);
});
}
}
runScene(key: string) {
this.game.scene.switch("selector", key)
}
}