2021-01-30 20:33:31 +01:00
|
|
|
const LogoNameIndex: string = 'logo';
|
|
|
|
const LogoResource: string = 'resources/logos/logo.png';
|
|
|
|
|
|
|
|
export const addLoader = (scene: Phaser.Scene): void => {
|
|
|
|
const loaderPlugin = scene.load.image(LogoNameIndex, LogoResource);
|
|
|
|
loaderPlugin.spritesheet(LogoNameIndex, LogoResource);
|
|
|
|
const promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
|
|
|
|
if (loaderPlugin.textureManager.exists(LogoNameIndex)) {
|
|
|
|
return res(scene.add.image(scene.game.renderer.width / 2, 100, LogoNameIndex));
|
|
|
|
}
|
|
|
|
loaderPlugin.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => {
|
|
|
|
res(scene.add.image(scene.game.renderer.width / 2, 100, LogoNameIndex))
|
|
|
|
});
|
|
|
|
});
|
2021-01-07 17:11:22 +01:00
|
|
|
|
|
|
|
const progress = scene.add.graphics();
|
|
|
|
scene.load.on('progress', (value: number) => {
|
|
|
|
progress.clear();
|
|
|
|
progress.fillStyle(0xffffff, 1);
|
|
|
|
progress.fillRect(0, 270, 800 * value, 60);
|
|
|
|
});
|
|
|
|
scene.load.on('complete', () => {
|
2021-01-30 20:33:31 +01:00
|
|
|
promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => {
|
|
|
|
resLoadingImage.destroy();
|
|
|
|
});
|
2021-01-07 17:11:22 +01:00
|
|
|
progress.destroy();
|
|
|
|
});
|
|
|
|
}
|