Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
 public SpriteAnimationFrame(SpriteFrame Frame, TimeSpan Duration)
 {
     this._Frame    = Frame;
     this._Duration = Duration;
 }
Exemplo n.º 3
0
 public SpriteAnimationFrame(SpriteFrame Frame, TimeSpan Duration)
 {
     this._Frame = Frame;
     this._Duration = Duration;
 }