Files
slop-game-opus5.5/app/static/js/scenes/BootScene.js
T
2026-09-24 17:57:54 +02:00

48 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Startszene: lädt Grafiken mit Fortschrittsbalken und erzeugt für alles, was nicht
* geladen werden konnte, Platzhalter. Danach geht es ins Hauptmenü.
* @module scenes/BootScene
*/
import { COLORS } from '../config.js';
import { queueAssets } from '../systems/Assets.js';
import { createPlaceholderTextures } from '../systems/Placeholders.js';
const BAR = Object.freeze({ width: 420, height: 14 });
export class BootScene extends Phaser.Scene {
constructor() {
super('Boot');
}
preload() {
const { width, height } = this.scale;
const context = this.registry.get('context');
/** @type {string[]} */
this.failedAssets = [];
const frame = this.add.graphics();
frame.lineStyle(2, COLORS.gold, 1);
frame.strokeRect(width / 2 - BAR.width / 2 - 4, height / 2 - BAR.height / 2 - 4, BAR.width + 8, BAR.height + 8);
const bar = this.add.graphics();
this.load.on('progress', (value) => {
bar.clear();
bar.fillStyle(COLORS.crimson, 1);
bar.fillRect(width / 2 - BAR.width / 2, height / 2 - BAR.height / 2, BAR.width * value, BAR.height);
});
// Fehlende Dateien sind kein Abbruchgrund – dafür gibt es Platzhalter.
this.load.on('loaderror', (file) => this.failedAssets.push(file.key));
queueAssets(this, context.staticBase);
}
create() {
if (this.failedAssets.length > 0) {
console.warn(`Glory Defense: ${this.failedAssets.length} Grafik(en) nicht geladen, verwende Platzhalter:`, this.failedAssets);
}
createPlaceholderTextures(this);
document.getElementById('boot-message')?.remove();
this.scene.start('Menu');
}
}