Exemple #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();
        }
Exemple #2
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();
        }