• Runtimes
  • Spine cocos2d-x seek animation and more

Hi, I'm running animation like this:

juiceAnim->setAnimation(0, "fillJuice", false);

Can I play fillJuice from 0 to x%? For example (50%) let's said it's 5 seconds long so I only want 0..2.5s part.
Can I seek animation so it will start from 2.5s?
Can I seek and stop in that place for example at 2.5s?

Regards

Related Discussions
...
spTrackEntry* entry = juiceAnim->setAnimation(0, "fillJuice", false);
// endTime is set to the animation duration by default.
entry->time = entry->endTime * 0.25; // Start at 25%.
entry->lastTime = entry->time; // Prevent events from 0% to 25% from firing.
entry->endTime *= 0.5; // End at 50%.

:beer:

I thought it's impossible, thanks!

To stop in place, you can say:

entry->timeScale = 0;

You can resume it by saying:

entry->timeScale = 1;

Neat trick, Pharan! :nerd:

21일 후

or should we add such code in SkeletonAnimation.cpp ?

void SkeletonAnimation::seek(float seekTime)
   {
      _skeleton->time = seekTime;
      if (_state)
      {
         for (int i = 0; i < _state->tracksCount; ++i) {
            spTrackEntry* current = _state->tracks[i];
            if (!current) continue;
            current->time = seekTime;
         }
      }

  spAnimationState_update(_state, 0.0f); 
  spAnimationState_apply(_state, _skeleton);
  spSkeleton_updateWorldTransform(_skeleton);
   }