• Runtimes
  • [Starling] Setting timeScale and eventThreshold

Hi Spine Forums - Newish to Spine and have a question regarding the Starling Runtime:

What is the best way to set both the timeScale and the eventThreshold of an animation - at the same moment?

Currently I have:

- SkeletonAnimation.state.setAnimationByName(0,"MyAnimtaion1",false).timeScale = 2;
- SkeletonAnimation.state.addAnimationByName(0,"MyAnimtaion2",false,1).timeScale = 1;

However, if I want to adjust the eventThreshold for "MyAnimtaion1", I can not do:

- SkeletonAnimation.state.setAnimationByName(0,"MyAnimtaion1",false).timeScale = 2;
- SkeletonAnimation.state.setAnimationByName(0,"MyAnimtaion1",false).eventThreshold = 1;
- SkeletonAnimation.state.aaddAnimationByName(0,"MyAnimtaion2",false,1).timeScale = 1;

because the 2nd 'setAnimationByName' wipes the 1st. And if I use an 'addAnimationsByName' then I just get another animation added.

I have looked at:

  • SkeletonAnimation.timeScale = .5;
    but that seems to globally takeover for all the animations.

Any insight is apprecieated. ChzBoi

Related Discussions
...

setAnimationByName returns a TrackEntry object.
You need to store that temporarily in a variable, then change the timeScale and eventThreshold.

var trackEntry : TrackEntry = SkeletonAnimation.state.setAnimationByName(0, "something", false);
trackEntry.timeScale = 2;
trackEntry.eventThreshold = 1;

Perfect - Thanks!

Shall I assume that "addAnimationByName" will also return a TrackEntry? <edit> it does!</edit>