• Runtimes
  • Set spine global timescale in javascript

My game has a global timescale, sometimes I slow down time for effect.

I'd like to synchronize any and all running spine animations to this new timescale value. Is there a straightforward way of modifying the timeScale of all animations at once?

Related Discussions
...
  • Đã chỉnh sửa

I'm afraid there's no global state in the Spine TypeScript runtime, and we rather not add any global state. However, simply keeping track of all AnimationState instances currently in use and setting the time scale on each of them when your global time scale changes should be simple enough to do.

Ah, you already have global state:

globalAutoUpdate

I just ended up adding two lines to my PIXI Spine runtime to do what I needed - much simpler than your recommended approach.

Spine.globalTimeScale = 1.0;

and, in the autoUpdateTransform method, divide the timeDelta by the globalTimeScale

timeDelta /= Spine.globalTimeScale;

I think adding this (tiny, two line) feature would be beneficial to many developers, instead of having to implement synchronization themselves.

Oh! The PIXI Spine runtime is not our runtime. It's a 3rd party runtime maintained by one of the awesome PIXI guys. Our spine-ts runtime, on which the PIXI runtime is based, does not have global state. Could you maybe file an issue on the PIXI spine runtime repository?