diff --git a/cocos2d/core/components/CCAnimation.js b/cocos2d/core/components/CCAnimation.js index a0e7d47a21..95c1fc4674 100644 --- a/cocos2d/core/components/CCAnimation.js +++ b/cocos2d/core/components/CCAnimation.js @@ -262,6 +262,14 @@ var Animation = cc.Class({ animator.playState(state, startTime); } + // Animation cannot be played when the component is not enabledInHierarchy. + // That would cause an error for the animation lost the reference after destroying the node. + // If users play the animation when the component is not enabledInHierarchy, + // we pause the animator here so that it will automatically resume the animation when users enable the component. + if (!this.enabledInHierarchy) { + animator.pause(); + } + this.currentClip = state.clip; } return state;