Skip to content

Commit

Permalink
Don't send messages from previous mixing animation
Browse files Browse the repository at this point in the history
  • Loading branch information
JCash committed Jan 11, 2024
1 parent 2421d14 commit 48ad603
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions defold-spine/src/comp_spine_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,34 @@ namespace dmSpine
{
SpineModelComponent* component = (SpineModelComponent*)state->userData;

// Events are explained here: http://esotericsoftware.com/spine-api-reference#AnimationStateListener
switch (type)
{
// case SP_ANIMATION_START:
// printf("Animation %s started on track %i\n", entry->animation->name, entry->trackIndex);
// break;
// case SP_ANIMATION_INTERRUPT:
// printf("Animation %s interrupted on track %i\n", entry->animation->name, entry->trackIndex);
// break;
// case SP_ANIMATION_END:
// printf("Animation %s ended on track %i\n", entry->animation->name, entry->trackIndex);
// break;
// case SP_ANIMATION_START:
// {
// printf("Animation %s started on track %i\n", entry->animation->name, entry->trackIndex);
// break;
// }
// case SP_ANIMATION_INTERRUPT:
// {
// printf("Animation %s interrupted on track %i\n", entry->animation->name, entry->trackIndex);
// break;
// }
// case SP_ANIMATION_END:
// {
// printf("Animation %s ended on track %i\n", entry->animation->name, entry->trackIndex);
// break;
// }
case SP_ANIMATION_COMPLETE:
{
if (entry->mixingTo != 0)
{
// While mixing, the previous animation completed.
// The problem is that the track is already owned by the new animation, and we
// cannot call the previous callback (as we haven't stored it)
return;
}

SpineAnimationTrack& track = component->m_AnimationTracks[entry->trackIndex];

// Should we look at the looping state?
Expand Down Expand Up @@ -586,7 +601,7 @@ namespace dmSpine
}
}
dmhash_t animation_id = dmHashString64(component->m_Resource->m_Ddf->m_DefaultAnimation);
PlayAnimation(component, animation_id, dmGameObject::PLAYBACK_LOOP_FORWARD, 0.0f,
PlayAnimation(component, animation_id, dmGameObject::PLAYBACK_LOOP_FORWARD, 0.0f,
component->m_Resource->m_Ddf->m_Offset, component->m_Resource->m_Ddf->m_PlaybackRate, 0);
// TODO: Is the default playmode specified anywhere?

Expand Down

0 comments on commit 48ad603

Please sign in to comment.