diff --git a/packages/sprite-animated/src/AnimatedSprite.js b/packages/sprite-animated/src/AnimatedSprite.js index 1c669e6..4f44a06 100644 --- a/packages/sprite-animated/src/AnimatedSprite.js +++ b/packages/sprite-animated/src/AnimatedSprite.js @@ -85,6 +85,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} @@ -285,6 +299,11 @@ this.cachedTint = 0xFFFFFF; this.uvs = this._texture._uvs.uvsFloat32; + if (this.updateAnchor) + { + this._anchor.copy(this._texture.defaultAnchor); + } + if (this.onFrameChange) { this.onFrameChange(this.currentFrame);