diff --git a/src/extras/AnimatedSprite.js b/src/extras/AnimatedSprite.js index 660fed7..13b804f 100644 --- a/src/extras/AnimatedSprite.js +++ b/src/extras/AnimatedSprite.js @@ -32,8 +32,9 @@ /** * @param {PIXI.Texture[]|FrameObject[]} textures - an array of {@link PIXI.Texture} or frame * objects that make up the animation + * @param {boolean} [autoUpdate=true] - Whether use PIXI.ticker.shared to auto update animation time. */ - constructor(textures) + constructor(textures, autoUpdate) { super(textures[0] instanceof core.Texture ? textures[0] : textures[0].texture); @@ -50,6 +51,14 @@ this.textures = textures; /** + * `true` uses PIXI.ticker.shared to auto update animation time. + * @type {boolean} + * @default true + * @private + */ + this._autoUpdate = autoUpdate !== false; + + /** * The speed that the AnimatedSprite will play at. Higher is faster, lower is slower * * @member {number} @@ -108,7 +117,10 @@ } this.playing = false; - core.ticker.shared.remove(this.update, this); + if (this._autoUpdate) + { + core.ticker.shared.remove(this.update, this); + } } /** @@ -123,7 +135,10 @@ } this.playing = true; - core.ticker.shared.add(this.update, this); + if (this._autoUpdate) + { + core.ticker.shared.add(this.update, this); + } } /**