load texture inside game scene instead inside of inside companion class
This commit is contained in:
parent
e5a196a42b
commit
187e21eed9
5 changed files with 20 additions and 15 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue