Skip to content

Commit

Permalink
Fix timer update after frame change callback call
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane-D committed Nov 12, 2024
1 parent 4aceabb commit d1bb108
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Binary file modified lib/libmd.a
Binary file not shown.
Binary file modified lib/libmd_debug.a
Binary file not shown.
16 changes: 11 additions & 5 deletions src/sprite_eng.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ bool SPR_getAutoAnimation(Sprite* sprite)
// for debug
checkSpriteValid(sprite, "SPR_getAutoAnimation");

return (sprite->timer != -1)?TRUE:FALSE;
return (sprite->timer == -1)?FALSE:TRUE;
}

void SPR_setAnimationLoop(Sprite* sprite, bool value)
Expand Down Expand Up @@ -1897,11 +1897,17 @@ static u16 updateFrame(Sprite* sprite, u16 status)
sprite->status = status;
sprite->onFrameChange(sprite);
status = sprite->status;
}

// init timer for this frame *after* calling callback (this allows SPR_isAnimationDone(..) to correctly report TRUE when animation is done)
if (SPR_getAutoAnimation(sprite))
sprite->timer = frame->timer;
// init timer for this frame *after* callback call and only if auto animation is enabled and timer was not manually changed in callback
if (sprite->timer == 0)
sprite->timer = frame->timer;
}
else
{
// init timer for this frame *after* callback call to allow SPR_isAnimationDone(..) to correctly report TRUE when animation is done in the callbacnk
if (SPR_getAutoAnimation(sprite))
sprite->timer = frame->timer;
}

// require tile data upload
if (status & SPR_FLAG_AUTO_TILE_UPLOAD)
Expand Down

1 comment on commit d1bb108

@D0NM
Copy link
Contributor

@D0NM D0NM commented on d1bb108 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!
You fixed the regression ^__^

Please sign in to comment.