public SpriteSheetAnimationClip(SpriteSheetAnimationClip clip) { Name = clip.Name; Duration = clip.Duration; SpriteSheetKeyFrame[] frames = new SpriteSheetKeyFrame[clip.Keyframes.Count]; clip.Keyframes.CopyTo(frames, 0); Keyframes = new List <SpriteSheetKeyFrame>(); Keyframes.AddRange(frames); Looped = clip.Looped; }
protected void GetCurrentCell(TimeSpan time) { time += currentTime; // If we reached the end, loop back to the start. while (time >= currentClip.Duration) { time -= currentClip.Duration; } if ((time < TimeSpan.Zero) || (time >= currentClip.Duration)) { throw new ArgumentOutOfRangeException("time"); } if (time < currentTime) { if (currentClip.Looped) { CurrentKeyframe = 0; } else { CurrentKeyframe = currentClip.Keyframes.Count - 1; StopClip(); } } currentTime = time; // Read key frame matrices. IList <SpriteSheetKeyFrame> keyframes = currentClip.Keyframes; while (CurrentKeyframe < keyframes.Count) { SpriteSheetKeyFrame keyframe = keyframes[CurrentKeyframe]; // Stop when we've read up to the current time position. if (keyframe.Time > currentTime) { break; } // Use this key frame. CurrentCell = keyframe.Cell; CurrentKeyframe++; } }