From 5e6fc5418185deb4e76ebdff960471bf8ce37523 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 11 Dec 2017 15:35:07 +0100 Subject: [PATCH] start fix tetris again --- src/game-lib-system-animation.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/game-lib-system-animation.js b/src/game-lib-system-animation.js index dd290d7..af0f34a 100644 --- a/src/game-lib-system-animation.js +++ b/src/game-lib-system-animation.js @@ -106,6 +106,15 @@ GameLib.System.Animation.prototype.instanceCreated = function(data) { this.textures[data.component.id] = data.component; this.textureIds = Object.keys(this.textures); } + + if (data.component instanceof GameLib.D3.Animation) { + this.animations[data.component.id] = data.component; + data.component.meshes.map( + function(mesh){ + this.attachAnimation(data.component, mesh) + }.bind(this) + ); + } }; GameLib.System.Animation.prototype.removeComponent = function(data) { @@ -120,6 +129,17 @@ GameLib.System.Animation.prototype.removeComponent = function(data) { this.textureIds = Object.keys(this.textures); } } + + if (data.component instanceof GameLib.D3.Animation) { + + data.component.meshes.map( + function(mesh){ + this.detachAnimation(mesh) + }.bind(this) + ); + + delete this.animations[data.component.id]; + } }; GameLib.System.Animation.prototype.textureAnimatedChange = function(data) {