diff --git a/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts b/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts index 354c5740..75c20a48 100644 --- a/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts +++ b/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts @@ -23,5 +23,7 @@ export const lazyLoadCompanionResource = (loader: LoaderPlugin, name: string): P loader.spritesheet(resource.name, resource.img, { frameWidth: 32, frameHeight: 32, endFrame: 12 }); loader.once(`filecomplete-spritesheet-${resource.name}`, () => resolve(resource.name)); + + loader.start(); // It's only automatically started during the Scene preload. }); } diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 5b541267..9f2bd1fd 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -227,9 +227,5 @@ export abstract class Character extends Container { } super.destroy(); this.playerName.destroy(); - - if (this.companion) { - this.companion.destroy(); - } } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 7cbefb39..5feb0607 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -854,6 +854,11 @@ ${escapedMessage} private removeAllRemotePlayers(): void { this.MapPlayersByKey.forEach((player: RemotePlayer) => { player.destroy(); + + if (player.companion) { + player.companion.destroy(); + } + this.MapPlayers.remove(player); }); this.MapPlayersByKey = new Map(); @@ -1243,6 +1248,11 @@ ${escapedMessage} console.error('Cannot find user with id ', userId); } else { player.destroy(); + + if (player.companion) { + player.companion.destroy(); + } + this.MapPlayers.remove(player); } this.MapPlayersByKey.delete(userId);