public virtual void Update(GameTime gameTime)
{
if (!Running)
return;
if (Direction == SpriteSheetDirection.LeftToRight)
{
if (!Loop && (CurrentFrame == LastFrame))
return;
currentFrame.X++;
// went past the right edge of the sprite sheet
if (currentFrame.X > 0)
{
currentFrame.X = 0;
currentFrame.Y++;
// did we go past the bottom edge?
if (currentFrame.Y > maxFrames.Y)
{
if (Loop)
currentFrame = FirstFrame;
}
}
}
else if (Direction == SpriteSheetDirection.RightToLeft)
{
if (!Loop && (CurrentFrame == LastFrame))
return;
currentFrame.X--;
// went past the left edge of the sprite sheet
if (currentFrame.X < 0)
{
currentFrame.X = maxFrames.X;
currentFrame.Y++;
// did we go past the bottom edge?
if (currentFrame.Y > maxFrames.Y)
{
if (Loop)
currentFrame = FirstFrame;
}
}
}
}