Skip to content

Commit

Permalink
Stop current animation if current animation asset is removed from the…
Browse files Browse the repository at this point in the history
… assets array
  • Loading branch information
vkalpias committed May 11, 2015
1 parent d201c6a commit 35a4ed3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/framework/components/animation/animation_component.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,20 @@ pc.extend(pc, function () {
if (this.animations && this.animations[asset.name]) {
delete this.animations[asset.name];
if (this.data.currAnim === asset.name) {
this.data.currAnim = null;
this.speed = 0;
this.data.playing = false;
if (this.data.skeleton) {
this.data.skeleton.setCurrentTime(0);
this.data.skeleton.setAnimation(null);
}
this._stopCurrentAnimation();
}
}
},

_stopCurrentAnimation: function () {
this.data.currAnim = null;
this.data.playing = false;
if (this.data.skeleton) {
this.data.skeleton.setCurrentTime(0);
this.data.skeleton.setAnimation(null);
}
},

onSetAnimations: function (name, oldValue, newValue) {
var data = this.data;

Expand Down Expand Up @@ -215,6 +218,10 @@ pc.extend(pc, function () {
if (asset) {
asset.off('change', this.onAssetChanged, this);
asset.off('remove', this.onAssetRemoved, this);

if (this.data.currAnim === asset.name) {
this._stopCurrentAnimation();
}
}
}
}
Expand Down

0 comments on commit 35a4ed3

Please sign in to comment.