Making code more robust regarding scene being null in Character class

Not sure how this can happen but it does.
Closes #1167
This commit is contained in:
David Négrier 2021-06-14 16:40:33 +02:00
parent 94333a7438
commit dcd44f283f

View file

@ -94,7 +94,7 @@ export abstract class Character extends Container {
public addTextures(textures: string[], frame?: string | number): void {
for (const texture of textures) {
if(!this.scene.textures.exists(texture)){
if(this.scene && !this.scene.textures.exists(texture)){
throw new TextureError('texture not found');
}
const sprite = new Sprite(this.scene, 0, 0, texture, frame);