[ts][pixi-v7][pixi-v8] Fix multiple autoUpdate calls setting multiple tickers.

This commit is contained in:
Davide Tantillo 2025-07-31 17:17:51 +02:00
parent e2bd01aef0
commit 97d2667818
2 changed files with 6 additions and 6 deletions

View File

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

View File

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