/** * 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'); } }