3
\$\begingroup\$

I'm using spine along with SFML. I have a character that is always animated. When he shots, I set an animation that affects only his arm. The arm goes up, but I need to stop this animation in the last frame while he keeps shooting.

I use this to make him walk

AnimationState_setAnimationByName(drawable->state, 0, "walk", true);

And this to make him shot

AnimationState_setAnimationByName(drawable->state, 1, "rshot", false);

I can't find a way in Spine c runtime to make this.

I could resolve this if I find a way to update manually tracks 0 and 1, instead of the full animation.

\$\endgroup\$
2
  • \$\begingroup\$ The last parameter, indicates to loop or not. So sending false, should technically stop the animation at the last frame. \$\endgroup\$
    – jgallant
    Sep 30, 2014 at 11:27
  • \$\begingroup\$ Jon, if I set it to false, instead of stopping at the last frame, the arm continues moving as the track "1" (that moves the arm) didn't exist (and the track 0 -walk- takes the responsability of moving it-) \$\endgroup\$
    – freesoul
    Sep 30, 2014 at 12:01

1 Answer 1

1
\$\begingroup\$

Finally I resolved this easily by editing the spine c runtime.

AnimationState.h

struct spTrackEntry {
    spAnimationState* const state;
    spTrackEntry() { stopAtEnd = false; };
    int/*bool*/ stopAtEnd;
    spTrackEntry* next;
    spTrackEntry* previous;
    spAnimation* animation;
    int/*bool*/loop;
    float delay, time, lastTime, endTime, timeScale;
    spAnimationStateListener listener;
    float mixTime, mixDuration, mix;

    void* rendererObject;
};

AnimationState.c

    /* End non-looping animation when it reaches its end time and there is no next entry. */
    if (!current->loop && current->lastTime >= current->endTime)
    {
        if (!current->stopAtEnd)
            spAnimationState_clearTrack(self, i);
    }

...

spTrackEntry* _spTrackEntry_create (spAnimationState* state) {
    spTrackEntry* self = NEW(spTrackEntry);
    CONST_CAST(spAnimationState*, self->state) = state;
    self->timeScale = 1;
    self->lastTime = -1;
    self->mix = 1;
    self->stopAtEnd = 0;
    return self;
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .