public void SetFrameSetQueue(FrameSet[] indexes, bool clearQueue = true) { if (indexes.Length == 0) { throw new ArgumentOutOfRangeException("indexes"); } if (clearQueue) { frameSetQueue.Clear(); } foreach (FrameSet set in indexes) { frameSetQueue.Enqueue(set); } FrameSet next = frameSetQueue.Dequeue(); SetFrameSet(next); }
public void SetFrameSet(FrameSet set, bool allowRedundancy = false) { if (set == null) { throw new ArgumentNullException("set"); } if (!allowRedundancy && frameSet == set) // avoid redundancy. { return; } frameSet = set; frame = set.Start; elapsed = TimeSpan.Zero; signaledAnimationCompleted = false; }
public override void UpdateOutput(GameTime gameTime) { elapsed += gameTime.ElapsedGameTime; if (elapsed >= frameSet.Interval) { frame++; elapsed = TimeSpan.Zero; } if (frame > frameSet.Length - 1) { if (frameSetQueue.Count != 0) { FrameSet next = frameSetQueue.Dequeue(); SetFrameSet(next); } else if (frameSet.Loop) { frame = frameSet.Start; } else { frame--; // stay on last frame. if (!signaledAnimationCompleted) { signaledAnimationCompleted = true; InvokeAnimationComplete(new AnimationCompleteArgs { FrameSet = frameSet, GameTime = gameTime }); } } } base.UpdateOutput(gameTime); }