/// <summary> /// Updates the animation /// </summary> /// <returns>The frame to be drawn</returns> public void Update() { int oldFrame = currentFrame; if (animationMode != AnimationMode.PAUSE) { if (++currentTick >= framerate) { currentTick = 0; currentFrame += direction; if (animationMode == AnimationMode.GOTO) { if (direction > 0 && currentFrame >= goToFrame) { currentFrame = goToFrame; animationMode = AnimationMode.PAUSE; } if (direction > 0 && currentFrame <= goToFrame) { currentFrame = goToFrame; animationMode = AnimationMode.PAUSE; } } if (animationMode == AnimationMode.LOOP) { if (loopMode == LoopMode.DIRECTION) { if (direction > 0 && currentFrame > loopTo) { currentFrame = loopFrom; } if (direction < 0 && currentFrame < loopTo) { currentFrame = loopFrom; } } if (loopMode == LoopMode.PINGPONG) { if (direction > 0 && currentFrame > loopTo) { currentFrame = loopTo; direction = -1; } if (direction < 0 && currentFrame < loopFrom) { currentFrame = loopFrom; direction = 1; } } if (loopMode == LoopMode.RANDOM) { currentFrame = random.Next(frames.Count - 1); } } } } Rectangle currentFrameRect = frames[currentFrame]; Rectangle oldFrameRect = frames[oldFrame]; if (oldFrame == currentFrame) { oldFrameRect = null; } else { currentFrameRect.MarkDirty(); currentFrameRect.Unhide(); oldFrameRect.MarkDirty(); oldFrameRect.Hide(); } fu = new FrameUpdate(currentFrameRect, oldFrameRect); }