Browse Source

[ts][pixi-v7][pixi-v8] Fix multiple autoUpdate calls setting multiple tickers (see #2900)

Davide Tantillo 1 month ago
parent
commit
a07b7176fd
2 changed files with 6 additions and 6 deletions
  1. 3 3
      spine-ts/spine-pixi-v7/src/Spine.ts
  2. 3 3
      spine-ts/spine-pixi-v8/src/Spine.ts

+ 3 - 3
spine-ts/spine-pixi-v7/src/Spine.ts

@@ -296,15 +296,15 @@ export class Spine extends Container {
 	beforeUpdateWorldTransforms: (object: Spine) => void = () => { };
 	afterUpdateWorldTransforms: (object: Spine) => void = () => { };
 
-	private _autoUpdate: boolean = true;
+	private _autoUpdate: boolean = false;
 	public get autoUpdate (): boolean {
 		return this._autoUpdate;
 	}
 	/** When `true`, the Spine AnimationState and the Skeleton will be automatically updated using the {@link Ticker.shared} instance. */
 	public set autoUpdate (value: boolean) {
-		if (value) {
+		if (value && !this._autoUpdate) {
 			Ticker.shared.add(this.internalUpdate, this);
-		} else {
+		} else if (!value && this._autoUpdate) {
 			Ticker.shared.remove(this.internalUpdate, this);
 		}
 		this._autoUpdate = value;

+ 3 - 3
spine-ts/spine-pixi-v8/src/Spine.ts

@@ -351,16 +351,16 @@ export class Spine extends ViewContainer {
 		this._debug = value;
 	}
 
-	private _autoUpdate = true;
+	private _autoUpdate = false;
 
 	public get autoUpdate (): boolean {
 		return this._autoUpdate;
 	}
 	/** When `true`, the Spine AnimationState and the Skeleton will be automatically updated using the {@link Ticker.shared} instance. */
 	public set autoUpdate (value: boolean) {
-		if (value) {
+		if (value && !this._autoUpdate) {
 			Ticker.shared.add(this.internalUpdate, this);
-		} else {
+		} else if (!value && this._autoUpdate) {
 			Ticker.shared.remove(this.internalUpdate, this);
 		}