From b09d88e2c871cd26683ed3eab3c4da728ecd8652 Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Wed, 24 May 2017 14:12:20 +0800 Subject: [PATCH] fixed animator not auto stop --- cocos2d/animation/animators.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos2d/animation/animators.js b/cocos2d/animation/animators.js index f7edbc1e22..ad0af17a0b 100644 --- a/cocos2d/animation/animators.js +++ b/cocos2d/animation/animators.js @@ -18,7 +18,10 @@ var animProto = Animator.prototype; animProto.update = function (dt) { var iterator = this._anims; var array = iterator.array; + var stoppedCount = 0; + var originLength = array.length; + for (iterator.i = 0; iterator.i < array.length; ++iterator.i) { var anim = array[iterator.i]; if (anim._isPlaying && !anim._isPaused) { @@ -30,7 +33,9 @@ animProto.update = function (dt) { } } - if (array.length === 0 || stoppedCount >= array.length) { + var allRemoved = array.length === 0; + var allStopped = stoppedCount >= originLength; + if (allRemoved || allStopped) { this.stop(); } };