@@ -123,7 +123,12 @@ export class Spine extends Container {
123
123
}
124
124
/** When `true`, the Spine AnimationState and the Skeleton will be automatically updated using the {@link Ticker.shared} instance. */
125
125
public set autoUpdate ( value : boolean ) {
126
- if ( value ) this . autoUpdateWarned = false ;
126
+ if ( value ) {
127
+ Ticker . shared . add ( this . internalUpdate , this ) ;
128
+ this . autoUpdateWarned = false ;
129
+ } else {
130
+ Ticker . shared . remove ( this . internalUpdate , this ) ;
131
+ }
127
132
this . _autoUpdate = value ;
128
133
}
129
134
@@ -166,14 +171,14 @@ export class Spine extends Container {
166
171
167
172
/** If {@link Spine.autoUpdate} is `false`, this method allows to update the AnimationState and the Skeleton with the given delta. */
168
173
public update ( deltaSeconds : number ) : void {
169
- if ( this . _autoUpdate && ! this . autoUpdateWarned ) {
174
+ if ( this . autoUpdate && ! this . autoUpdateWarned ) {
170
175
console . warn ( "You are calling update on a Spine instance that has autoUpdate set to true. This is probably not what you want." ) ;
171
176
this . autoUpdateWarned = true ;
172
177
}
173
- this . internalUpdate ( deltaSeconds ) ;
178
+ this . internalUpdate ( 0 , deltaSeconds ) ;
174
179
}
175
180
176
- protected internalUpdate ( deltaSeconds ?: number ) : void {
181
+ protected internalUpdate ( _deltaFrame : number , deltaSeconds ?: number ) : void {
177
182
// Because reasons, pixi uses deltaFrames at 60fps. We ignore the default deltaFrames and use the deltaSeconds from pixi ticker.
178
183
const delta = deltaSeconds ?? Ticker . shared . deltaMS / 1000 ;
179
184
this . state . update ( delta ) ;
@@ -186,7 +191,6 @@ export class Spine extends Container {
186
191
187
192
/** Render the meshes based on the current skeleton state, render debug information, then call {@link Container.updateTransform}. */
188
193
public override updateTransform ( ) : void {
189
- if ( this . _autoUpdate ) this . internalUpdate ( ) ;
190
194
this . renderMeshes ( ) ;
191
195
this . sortChildren ( ) ;
192
196
this . debug ?. renderDebug ( this ) ;
0 commit comments