removed Sprite afterFrame func. The same functionality can be achieved by listening to indexChange event

This commit is contained in:
Eric Rowell 2013-12-15 12:55:01 -08:00
parent c5dd9e1090
commit d3eb9990bd
2 changed files with 4 additions and 20 deletions

View File

@ -126,13 +126,7 @@
this.anim.setLayers(layer); this.anim.setLayers(layer);
this.interval = setInterval(function() { this.interval = setInterval(function() {
var index = that.getIndex();
that._updateIndex(); that._updateIndex();
if(that.afterFrameFunc && index === that.afterFrameIndex) {
that.afterFrameFunc();
delete that.afterFrameFunc;
delete that.afterFrameIndex;
}
}, 1000 / this.getFrameRate()); }, 1000 / this.getFrameRate());
this.anim.start(); this.anim.start();
@ -146,17 +140,6 @@
this.anim.stop(); this.anim.stop();
clearInterval(this.interval); 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() { _updateIndex: function() {
var index = this.getIndex(), var index = this.getIndex(),
animation = this.getAnimation(), animation = this.getAnimation(),

View File

@ -108,9 +108,10 @@ suite('Sprite', function() {
// kick once // kick once
setTimeout(function() { setTimeout(function() {
sprite.setAnimation('kicking'); sprite.setAnimation('kicking');
sprite.on('indexChange', function(evt) {
sprite.afterFrame(5, function() { if (evt.newVal === 0 && this.getAnimation() === 'kicking') {
sprite.setAnimation('standing'); sprite.setAnimation('standing');
}
}); });
}, 2000); }, 2000);
setTimeout(function() { setTimeout(function() {