Initial commit
This commit is contained in:
41
src/scenes/SplashScene.ts
Normal file
41
src/scenes/SplashScene.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import Phaser from "phaser";
|
||||
import { Scene } from 'phaser';
|
||||
|
||||
export class SplashScene extends Scene {
|
||||
constructor() {
|
||||
super("SplashScene");
|
||||
}
|
||||
|
||||
preload() {
|
||||
this.load.image('splash', 'splash_bg.png');
|
||||
}
|
||||
|
||||
create() {
|
||||
const { width, height } = this.scale;
|
||||
|
||||
// Background (Placeholder for Image)
|
||||
// If we successfully load the image 'splash', we use it.
|
||||
if (this.textures.exists('splash')) {
|
||||
this.add.image(width / 2, height / 2, 'splash').setDisplaySize(width, height);
|
||||
} else {
|
||||
this.add.rectangle(0, 0, width, height, 0x110022).setOrigin(0);
|
||||
this.add.text(width/2, height/2, "ROGUE LEGACY", {
|
||||
fontSize: "48px",
|
||||
color: "#ffffff",
|
||||
fontStyle: "bold"
|
||||
}).setOrigin(0.5);
|
||||
}
|
||||
|
||||
// Fade In
|
||||
this.cameras.main.fadeIn(1000, 0, 0, 0);
|
||||
|
||||
// Fade Out after delay
|
||||
this.time.delayedCall(2500, () => {
|
||||
this.cameras.main.fadeOut(1000, 0, 0, 0);
|
||||
});
|
||||
|
||||
this.cameras.main.once(Phaser.Cameras.Scene2D.Events.FADE_OUT_COMPLETE, () => {
|
||||
this.scene.start("StartScene");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user