From d3eb9990bdd90060f6f1ede92cc3a24e1becee0c Mon Sep 17 00:00:00 2001 From: Eric Rowell Date: Sun, 15 Dec 2013 12:55:01 -0800 Subject: [PATCH] removed Sprite afterFrame func. The same functionality can be achieved by listening to indexChange event --- src/shapes/Sprite.js | 17 ----------------- test/unit/shapes/Sprite-test.js | 7 ++++--- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/shapes/Sprite.js b/src/shapes/Sprite.js index da8e0ea0..832ab0a5 100644 --- a/src/shapes/Sprite.js +++ b/src/shapes/Sprite.js @@ -126,13 +126,7 @@ this.anim.setLayers(layer); this.interval = setInterval(function() { - var index = that.getIndex(); that._updateIndex(); - if(that.afterFrameFunc && index === that.afterFrameIndex) { - that.afterFrameFunc(); - delete that.afterFrameFunc; - delete that.afterFrameIndex; - } }, 1000 / this.getFrameRate()); this.anim.start(); @@ -146,17 +140,6 @@ this.anim.stop(); clearInterval(this.interval); }, - /** - * set after frame event handler - * @method - * @memberof Kinetic.Sprite.prototype - * @param {Integer} index frame index - * @param {Function} func function to be executed after frame has been drawn - */ - afterFrame: function(index, func) { - this.afterFrameIndex = index; - this.afterFrameFunc = func; - }, _updateIndex: function() { var index = this.getIndex(), animation = this.getAnimation(), diff --git a/test/unit/shapes/Sprite-test.js b/test/unit/shapes/Sprite-test.js index b839a555..f063b9b1 100644 --- a/test/unit/shapes/Sprite-test.js +++ b/test/unit/shapes/Sprite-test.js @@ -108,9 +108,10 @@ suite('Sprite', function() { // kick once setTimeout(function() { sprite.setAnimation('kicking'); - - sprite.afterFrame(5, function() { - sprite.setAnimation('standing'); + sprite.on('indexChange', function(evt) { + if (evt.newVal === 0 && this.getAnimation() === 'kicking') { + sprite.setAnimation('standing'); + } }); }, 2000); setTimeout(function() {