load texture inside game scene instead inside of inside companion class

This commit is contained in:
Johannes Berthel 2021-04-06 19:10:18 +02:00
parent e5a196a42b
commit 187e21eed9
5 changed files with 20 additions and 15 deletions

View file

@ -23,7 +23,7 @@ export class Companion extends Container {
private direction: PlayerAnimationDirections;
private animationType: PlayerAnimationTypes;
constructor(scene: Phaser.Scene, x: number, y: number, name: string) {
constructor(scene: Phaser.Scene, x: number, y: number, name: string, texturePromise: Promise<string>) {
super(scene, x + 14, y + 4);
this.sprites = new Map<string, Sprite>();
@ -37,12 +37,10 @@ export class Companion extends Container {
this.companionName = name;
lazyLoadCompanionResource(this.scene.load, this.companionName)
.then(resource => {
this.addResource(resource);
this.invisible = false;
})
.catch(error => console.error(error));
texturePromise.then(resource => {
this.addResource(resource);
this.invisible = false;
})
this.scene.physics.world.enableBody(this);