chore: error handling

This commit is contained in:
cha0s 2020-06-21 11:22:10 -05:00
parent 5f701f1525
commit a906073b91
3 changed files with 13 additions and 5 deletions

View File

@ -80,6 +80,8 @@ export class Resource extends decorate(class {}) {
}); });
} }
return json; return json;
}).catch((error) => {
console.error(`Failed loading '${uri}'.`);
}); });
} }

View File

@ -13,12 +13,14 @@ export class AnimationView extends Renderable {
this.animation = animation; this.animation = animation;
this.container = new Container(); this.container = new Container();
if (hasGraphics) { if (hasGraphics) {
if (this.animation.imageUri) {
Image.load(this.animation.imageUri).then((image) => { Image.load(this.animation.imageUri).then((image) => {
this.sprite = new Sprite(image); this.sprite = new Sprite(image);
this.container.addChild(this.sprite); this.container.addChild(this.sprite);
this.resetSourceRectangle(); this.resetSourceRectangle();
}); });
} }
}
animation.on( animation.on(
['directionChanged', 'indexChanged'], ['directionChanged', 'indexChanged'],
this.onAnimationChanged, this.onAnimationChanged,

View File

@ -128,6 +128,8 @@ export default class Animated extends decorate(Trait) {
}); });
// Bounding box update. // Bounding box update.
this.entity.updateVisibleBoundingBox(); this.entity.updateVisibleBoundingBox();
}).catch((error) => {
console.error(`Failed loading some or all animations.`);
}); });
} }
@ -156,6 +158,8 @@ export default class Animated extends decorate(Trait) {
} }
}); });
this.setSpriteScale(); this.setSpriteScale();
}).catch((error) => {
console.error(`Failed loading some or all animation images.`);
}); });
} }