示例#1
0
文件: Sprite.cs 项目: Octanum/Corvus
        /// <summary>
        /// Creates a new Sprite from the specified SpriteData instance.
        /// </summary>
        public Sprite(SpriteData Data)
        {
            SpriteFrameCollection Frames = new SpriteFrameCollection();
            foreach(var FrameData in Data.Frames) {
                var SpriteFrame = new SpriteFrame(FrameData.Name, FrameData.Source, this);
                Frames.Add(SpriteFrame);
            }
            SpriteAnimationCollection Animations = new SpriteAnimationCollection();
            foreach(var Animation in Data.Animations) {
                List<SpriteAnimationFrame> AnimationFrames = new List<SpriteAnimationFrame>();
                foreach(var Duration in Animation.FrameDurations) {
                    var Frame = Frames[Duration.Key];
                    SpriteAnimationFrame AnimationFrame = new SpriteAnimationFrame(Frame, Duration.Value);
                    AnimationFrames.Add(AnimationFrame);
                }
                Animations.Add(new SpriteAnimation(Animation.Name, Animation.IsLooped, Animation.IsDefault, AnimationFrames));
            }

            this._Texture = Data.Texture;
            this._Frames = Frames;
            this._Animations = Animations;
            this._ActiveAnimation = GetDefaultAnimation();
        }
示例#2
0
 public SpriteAnimationFrame(SpriteFrame Frame, TimeSpan Duration)
 {
     this._Frame    = Frame;
     this._Duration = Duration;
 }
示例#3
0
 public SpriteAnimationFrame(SpriteFrame Frame, TimeSpan Duration)
 {
     this._Frame = Frame;
     this._Duration = Duration;
 }