🔧 Jan 8 Fix MasterWeatherSystem Null Reference Error

 BUG FIX #3 - Runtime Error:

**Problem:**
- MasterWeatherSystem.js:460 - rainEmitter.setSpeedX is not a function
- No null check before accessing particle emitter methods
- Crashed when entering GameScene (New Game)

**Root Cause:**
- Particle emitters not initialized yet when update() called
- Missing method existence check

**Solution:**
- Added null checks: this.rainEmitter && this.snowEmitter
- Added method existence check: typeof setSpeedX === 'function'
- Prevents crash if emitters not ready

**Changes:**
- Line 458: Added null + method check for rainEmitter
- Line 463: Added null + method check for snowEmitter

 Game now loads past menu into GameScene
 Ready for TestVisualAudioScene test

**Test:** game.scene.start('TestVisualAudioScene')
This commit is contained in:
2026-01-08 16:15:56 +01:00
parent 1a634e6cd3
commit 0bec0eb07a

View File

@@ -455,12 +455,13 @@ export default class MasterWeatherSystem {
}
// Update rain/snow particle positions based on wind
if (this.rainEmitter.active) {
// ✅ NULL CHECK: Ensure emitter exists and has setSpeedX method
if (this.rainEmitter && this.rainEmitter.active && typeof this.rainEmitter.setSpeedX === 'function') {
const windInfluence = this.windSystem.wind.strength * 20;
this.rainEmitter.setSpeedX({ min: -windInfluence, max: windInfluence });
}
if (this.snowEmitter.active) {
if (this.snowEmitter && this.snowEmitter.active && typeof this.snowEmitter.setSpeedX === 'function') {
const windInfluence = this.windSystem.wind.strength * 30;
this.snowEmitter.setSpeedX({ min: -windInfluence, max: windInfluence });
}