This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
welcomeScene.ts
64 lines (56 loc) · 1.76 KB
/
welcomeScene.ts
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
import "phaser";
export class WelcomeScene extends Phaser.Scene {
constructor() {
super({ key: "WelcomeScene" });
}
create(): void {
// Request welcome message from the server
fetch("http://your-server-url/welcome-message")
.then((response) => response.text())
.then((welcomeMessage) => {
// Display the received welcome message
const welcomeText = this.add.text(200, 200, welcomeMessage, {
fontSize: "24px",
color: "#ffffff",
});
// Add a button to proceed to the login scene
const loginButton = this.add.text(300, 300, "Login", {
fontSize: "24px",
color: "#ffffff",
backgroundColor: "#00ff00",
padding: {
x: 10,
y: 5,
},
});
loginButton.setInteractive();
loginButton.on("pointerdown", () => {
// Transition to the login scene when the button is clicked
this.scene.start("LoginScene");
});
})
.catch((error) => {
// Handle any errors related to fetching the welcome message
console.error("Error fetching welcome message:", error);
// Fallback welcome message in case of error
const welcomeText = this.add.text(200, 200, "Welcome to the Game Lobby", {
fontSize: "24px",
color: "#ffffff",
});
// Add a button to proceed to the login scene
const loginButton = this.add.text(300, 300, "Login", {
fontSize: "24px",
color: "#ffffff",
backgroundColor: "#00ff00",
padding: {
x: 10,
y: 5,
},
});
loginButton.setInteractive();
loginButton.on("pointerdown", () => {
// Transition to the login scene when the button is clicked
this.scene.start("LoginScene");
});
});
}