mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-30 02:36:11 +00:00
clean loading scene and let mobile see intro (#2316)
This commit is contained in:
parent
942cbb2181
commit
9e1da3d548
@ -24,6 +24,8 @@ import { Biome } from "#enums/biome";
|
|||||||
import { TrainerType } from "#enums/trainer-type";
|
import { TrainerType } from "#enums/trainer-type";
|
||||||
|
|
||||||
export class LoadingScene extends SceneBase {
|
export class LoadingScene extends SceneBase {
|
||||||
|
readonly LOAD_EVENTS = Phaser.Loader.Events;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("loading");
|
super("loading");
|
||||||
|
|
||||||
@ -35,10 +37,6 @@ export class LoadingScene extends SceneBase {
|
|||||||
Utils.localPing();
|
Utils.localPing();
|
||||||
this.load["manifest"] = this.game["manifest"];
|
this.load["manifest"] = this.game["manifest"];
|
||||||
|
|
||||||
if (!isMobile()) {
|
|
||||||
this.load.video("intro_dark", "images/intro_dark.mp4", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loadImage("loading_bg", "arenas");
|
this.loadImage("loading_bg", "arenas");
|
||||||
this.loadImage("logo", "");
|
this.loadImage("logo", "");
|
||||||
this.loadImage("pride-update", "events");
|
this.loadImage("pride-update", "events");
|
||||||
@ -421,58 +419,46 @@ export class LoadingScene extends SceneBase {
|
|||||||
});
|
});
|
||||||
disclaimerDescriptionText.setOrigin(0.5, 0.5);
|
disclaimerDescriptionText.setOrigin(0.5, 0.5);
|
||||||
|
|
||||||
disclaimerText.setVisible(false);
|
loadingGraphics.push(bg, graphics, progressBar, progressBox, logo, percentText, assetText, disclaimerText, disclaimerDescriptionText);
|
||||||
disclaimerDescriptionText.setVisible(false);
|
|
||||||
|
|
||||||
const intro = this.add.video(0, 0);
|
|
||||||
intro.setOrigin(0, 0);
|
|
||||||
intro.setScale(3);
|
|
||||||
|
|
||||||
this.load.on("progress", (value: string) => {
|
|
||||||
const parsedValue = parseFloat(value);
|
|
||||||
percentText.setText(`${Math.floor(parsedValue * 100)}%`);
|
|
||||||
progressBar.clear();
|
|
||||||
progressBar.fillStyle(0xffffff, 0.8);
|
|
||||||
progressBar.fillRect(midWidth - 320, 360, 640 * parsedValue, 64);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.load.on("fileprogress", file => {
|
|
||||||
assetText.setText(i18next.t("menu:loadingAsset", { assetName: file.key }));
|
|
||||||
});
|
|
||||||
|
|
||||||
loadingGraphics.push(bg, graphics, progressBar, progressBox, logo, percentText, assetText);
|
|
||||||
|
|
||||||
if (!mobile) {
|
if (!mobile) {
|
||||||
loadingGraphics.map(g => g.setVisible(false));
|
loadingGraphics.map(g => g.setVisible(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
const destroyLoadingAssets = () => {
|
const intro = this.add.video(0, 0);
|
||||||
intro.destroy();
|
intro.on(Phaser.GameObjects.Events.VIDEO_COMPLETE, (video: Phaser.GameObjects.Video) => {
|
||||||
bg.destroy();
|
this.tweens.add({
|
||||||
logo.destroy();
|
targets: intro,
|
||||||
progressBar.destroy();
|
duration: 500,
|
||||||
progressBox.destroy();
|
alpha: 0,
|
||||||
percentText.destroy();
|
ease: "Sine.easeIn",
|
||||||
assetText.destroy();
|
onComplete: () => video.destroy(),
|
||||||
};
|
});
|
||||||
|
loadingGraphics.forEach(g => g.setVisible(true));
|
||||||
|
});
|
||||||
|
intro.setOrigin(0, 0);
|
||||||
|
intro.setScale(3);
|
||||||
|
|
||||||
this.load.on("filecomplete", key => {
|
this.load.once(this.LOAD_EVENTS.START, () => {
|
||||||
|
// videos do not need to be preloaded
|
||||||
|
intro.loadURL("images/intro_dark.mp4", true);
|
||||||
|
if (mobile) {
|
||||||
|
intro.video.setAttribute("webkit-playsinline", "webkit-playsinline");
|
||||||
|
intro.video.setAttribute("playsinline", "playsinline");
|
||||||
|
}
|
||||||
|
intro.play();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.load.on(this.LOAD_EVENTS.PROGRESS , (progress: number) => {
|
||||||
|
percentText.setText(`${Math.floor(progress * 100)}%`);
|
||||||
|
progressBar.clear();
|
||||||
|
progressBar.fillStyle(0xffffff, 0.8);
|
||||||
|
progressBar.fillRect(midWidth - 320, 360, 640 * progress, 64);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.load.on(this.LOAD_EVENTS.FILE_COMPLETE, (key: string) => {
|
||||||
|
assetText.setText(i18next.t("menu:loadingAsset", { assetName: key }));
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "intro_dark":
|
|
||||||
intro.load("intro_dark");
|
|
||||||
intro.on("complete", () => {
|
|
||||||
this.tweens.add({
|
|
||||||
targets: intro,
|
|
||||||
duration: 500,
|
|
||||||
alpha: 0,
|
|
||||||
ease: "Sine.easeIn"
|
|
||||||
});
|
|
||||||
loadingGraphics.map(g => g.setVisible(true));
|
|
||||||
disclaimerText.setVisible(true);
|
|
||||||
disclaimerDescriptionText.setVisible(true);
|
|
||||||
});
|
|
||||||
intro.play();
|
|
||||||
break;
|
|
||||||
case "loading_bg":
|
case "loading_bg":
|
||||||
bg.setTexture("loading_bg");
|
bg.setTexture("loading_bg");
|
||||||
if (mobile) {
|
if (mobile) {
|
||||||
@ -488,7 +474,7 @@ export class LoadingScene extends SceneBase {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.load.on("complete", () => destroyLoadingAssets());
|
this.load.on(this.LOAD_EVENTS.COMPLETE, () => loadingGraphics.forEach(go => go.destroy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
get gameHeight() {
|
get gameHeight() {
|
||||||
|
Loading…
Reference in New Issue
Block a user