diff --git a/src/extras/AnimatedSprite.js b/src/extras/AnimatedSprite.js index 134d058..515a41e 100644 --- a/src/extras/AnimatedSprite.js +++ b/src/extras/AnimatedSprite.js @@ -88,6 +88,20 @@ this.loop = true; /** + * Update anchor to [Texture's defaultAnchor]{@link PIXI.Texture#defaultAnchor} when frame changes. + * + * Useful with [sprite sheet animations]{@link PIXI.Spritesheet#animations} created with tools. + * Changing anchor for each frame allows to pin sprite origin to certain moving feature + * of the frame (e.g. left foot). + * + * Note: Enabling this will override any previously set `anchor` on each frame change. + * + * @member {boolean} + * @default false + */ + this.updateAnchor = false; + + /** * Function to call when a AnimatedSprite finishes playing * * @member {Function} @@ -286,6 +300,11 @@ this._textureID = -1; this.cachedTint = 0xFFFFFF; + if (this.updateAnchor) + { + this._anchor.copy(this._texture.defaultAnchor); + } + if (this.onFrameChange) { this.onFrameChange(this.currentFrame);