Update method at Animation class:
public void Update(GameTime gameTime)
{
Timer += gameTime.ElapsedGameTime.Milliseconds;
if (Timer > FrameTime){
CurrentFrame++;
if (CurrentFrame == TotalFrames)
{
CurrentFrame = 0;
Done = true;
}
Timer = 0;
}
}
How to adapt this code to make animation single loop?
You're setting Done
to true, which is good, but you forgot to use that variable to check again.
So you should add a to your first if-statement if Done
is false:
if (Timer > FrameTime && Done == false) {