From b52707f79dd0ff0f5d56d273a28f555aee0fca8b Mon Sep 17 00:00:00 2001 From: Antriel Date: Fri, 13 Apr 2018 09:58:33 +0200 Subject: [PATCH] Fix Animation component pause() --- src/gameobjects/components/Animation.js | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gameobjects/components/Animation.js b/src/gameobjects/components/Animation.js index daed8c2b9..f6fcd1657 100644 --- a/src/gameobjects/components/Animation.js +++ b/src/gameobjects/components/Animation.js @@ -817,24 +817,26 @@ var Animation = new Class({ */ update: function (timestamp, delta) { - if (this.currentAnim && (this.isPlaying || !this.currentAnim.paused)) + if (!this.currentAnim || !this.isPlaying || this.currentAnim.paused) { - this.accumulator += delta * this._timeScale; + return; + } - if (this._pendingStop === 1) + this.accumulator += delta * this._timeScale; + + if (this._pendingStop === 1) + { + this._pendingStopValue -= delta; + + if (this._pendingStopValue <= 0) { - this._pendingStopValue -= delta; - - if (this._pendingStopValue <= 0) - { - return this.currentAnim.completeAnimation(this); - } + return this.currentAnim.completeAnimation(this); } + } - if (this.accumulator >= this.nextTick) - { - this.currentAnim.setFrame(this); - } + if (this.accumulator >= this.nextTick) + { + this.currentAnim.setFrame(this); } },