From d4636e9e8179fa71c86b0eaf0a992288feefb73d Mon Sep 17 00:00:00 2001 From: gotenxds Date: Fri, 27 May 2016 17:58:54 +0300 Subject: [PATCH] Added a reverseOnce method. --- src/animation/Animation.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 9aaf5c1de..7ed8227cc 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -252,6 +252,19 @@ Phaser.Animation.prototype = { this.reversed = !this.reversed; }, + /** + * Reverses the animation direction for the current/next animation only + * Once the onComplete event is called this method will be called again and revert + * the reversed state. + * + * @method Phaser.Animation#reverseOnce + * */ + reverseOnce: function () { + this.reverse(); + + this.onComplete.addOnce(this.reverse.bind(this)) + }, + /** * Sets this animations playback to a given frame with the given ID. *