LoginSignup
3
0

More than 5 years have passed since last update.

Spine のアニメーションを任意の場所から開始する (cocos2d-x での場合)

Posted at

Spine のアニメーションを任意の場所から開始する

デザイナーさんから「とあるシーンの進行中にアニメーションを追加したいんだけど、そのアニメを他の再生中アニメと同じ状態で再生開始させて欲しい」と言われた時にとった対応です。

Spine で setAnimation() でアニメーション再生を指定した際は内部で update(0) が呼ばれており、問答無用でアニメが最初から再生されていました。
この update() の引数で再生開始箇所をコントロールできることは分かったのですが、今再生中のカウントがどれなのか探すのに難儀したので備忘録も兼ねて下記に記します。

spine::SkeltonAnimation* anotherAnimation = {再生中のアニメ};
spine::SkeltonAnimation* currentAnimation = {追加しようとしているアニメ};

float updateCount = anotherAnimation->getCurrent()->trackTime;
currentAnimation->setAnimation(0, "animationName", isLoop);
currentAnimation->update(updateCount);

構造体 spTrackEntry の trackTime が再生後の経過カウントのようです。
これを指定することで他のアニメと再生位置を合わせる事ができました。
(不適切だったり間違ってたりしたらごめんなさい…)

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0