Skip to content

Commit

Permalink
Make sure that no frames over or under the total are played
Browse files Browse the repository at this point in the history
  • Loading branch information
justalemon committed Dec 19, 2023
1 parent a18842e commit 5af8c5f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion LemonUI/Elements/ScaledAnim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,19 @@ public override void Draw()

float progress = (time - (float)start) / Duration;
int totalFrames = (int)((duration / 1000.0f) * frameRate);
int currentFrame = (int)(totalFrames * progress);
int currentFrame = (int)(totalFrames * progress) + 1;

if (progress < 0)
{
currentFrame = 1;
start = time;
}
else if (currentFrame >= totalFrames)
{
currentFrame = totalFrames;
start = time;
}

Texture = currentFrame.ToString();

base.Draw();
Expand Down

0 comments on commit 5af8c5f

Please sign in to comment.