diff --git a/src/extras/AnimatedSprite.js b/src/extras/AnimatedSprite.js index a24f07c..992a4e0 100644 --- a/src/extras/AnimatedSprite.js +++ b/src/extras/AnimatedSprite.js @@ -88,6 +88,13 @@ */ this.onFrameChange = null; + /** + * Function to call when 'loop' is true, and an AnimatedSprite is played and loops around to start again + * + * @member {Function} + */ + this.onLoop = null; + /** * Elapsed time since animation has been started, used internally to display current texture * @@ -239,6 +246,18 @@ } else if (previousFrame !== this.currentFrame) { + if (this.loop && this.onLoop) + { + if (this.animationSpeed > 0 && this.currentFrame < previousFrame) + { + this.onLoop(); + } + else if (this.animationSpeed < 0 && this.currentFrame > previousFrame) + { + this.onLoop(); + } + } + this.updateTexture(); } }