diff --git a/app/ecs/components/sprite.js b/app/ecs/components/sprite.js index eab0559..944ff30 100644 --- a/app/ecs/components/sprite.js +++ b/app/ecs/components/sprite.js @@ -22,13 +22,14 @@ export default class Sprite extends Component { super.frame = this.frames ? frame % this.frames : 0; } get frames() { - return this.animation - ? ( - this.$$sourceJson.animations - ? this.$$sourceJson.animations[this.animation].length - : 0 - ) - : 0; + if ( + !this.animation + || !this.$$sourceJson.animations + || !(this.animation in this.$$sourceJson.animations) + ) { + return 0; + } + return this.$$sourceJson.animations[this.animation].length; } get scale() { return {x: this.scaleX, y: this.scaleY};