Merge pull request #690 from thecodingmachine/newLogo
Update Loading page
This commit is contained in:
commit
8572959cb0
BIN
front/dist/resources/logos/logo.png
vendored
Normal file
BIN
front/dist/resources/logos/logo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -1,14 +1,50 @@
|
|||||||
|
import ImageFrameConfig = Phaser.Types.Loader.FileTypes.ImageFrameConfig;
|
||||||
|
|
||||||
export const addLoader = (scene:Phaser.Scene): void => {
|
const LogoNameIndex: string = 'logoLoading';
|
||||||
const loadingText = scene.add.text(scene.game.renderer.width / 2, 200, 'Loading');
|
const TextName: string = 'Loading...';
|
||||||
|
const LogoResource: string = 'resources/logos/logo.png';
|
||||||
|
const LogoFrame: ImageFrameConfig = {frameWidth: 307, frameHeight: 59};
|
||||||
|
|
||||||
|
export const addLoader = (scene: Phaser.Scene): void => {
|
||||||
|
let loadingText: Phaser.GameObjects.Text|null = null;
|
||||||
|
const loadingBarWidth: number = Math.floor(scene.game.renderer.width / 3);
|
||||||
|
const loadingBarHeight: number = 16;
|
||||||
|
const padding: number = 5;
|
||||||
|
|
||||||
|
const promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
|
||||||
|
if(scene.load.textureManager.exists(LogoNameIndex)){
|
||||||
|
return res(scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex));
|
||||||
|
}else{
|
||||||
|
//add loading if logo image is not ready
|
||||||
|
loadingText = scene.add.text(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 50, TextName);
|
||||||
|
}
|
||||||
|
scene.load.spritesheet(LogoNameIndex, LogoResource, LogoFrame);
|
||||||
|
scene.load.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => {
|
||||||
|
if(loadingText){
|
||||||
|
loadingText.destroy();
|
||||||
|
}
|
||||||
|
return res(scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const progressContainer = scene.add.graphics();
|
||||||
const progress = scene.add.graphics();
|
const progress = scene.add.graphics();
|
||||||
|
progressContainer.fillStyle(0x444444, 0.8);
|
||||||
|
progressContainer.fillRect((scene.game.renderer.width - loadingBarWidth) / 2 - padding, scene.game.renderer.height / 2 + 50 - padding, loadingBarWidth + padding * 2, loadingBarHeight + padding * 2);
|
||||||
|
|
||||||
scene.load.on('progress', (value: number) => {
|
scene.load.on('progress', (value: number) => {
|
||||||
progress.clear();
|
progress.clear();
|
||||||
progress.fillStyle(0xffffff, 1);
|
progress.fillStyle(0xBBBBBB, 1);
|
||||||
progress.fillRect(0, 270, 800 * value, 60);
|
progress.fillRect((scene.game.renderer.width - loadingBarWidth) / 2, scene.game.renderer.height / 2 + 50, loadingBarWidth * value, loadingBarHeight);
|
||||||
});
|
});
|
||||||
scene.load.on('complete', () => {
|
scene.load.on('complete', () => {
|
||||||
loadingText.destroy();
|
if(loadingText){
|
||||||
|
loadingText.destroy();
|
||||||
|
}
|
||||||
|
promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => {
|
||||||
|
resLoadingImage.destroy();
|
||||||
|
});
|
||||||
progress.destroy();
|
progress.destroy();
|
||||||
|
progressContainer.destroy();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user