Пример #1
0
        /// <summary>
        /// Creates a new animated bitmap
        /// </summary>
        /// <param name="bitmapReference">The backing bitmap reference</param>
        public AnimatedBitmap(BitmapReference bitmapReference)
            : base(bitmapReference)
        {
            var xml = Module.Get<IFileSystem>().LoadXmlFile(bitmapReference.Name+".xml");
            Width = (int)xml.Root.Attribute("width");
            Height = (int)xml.Root.Attribute("height");
            foreach (var animationNode in xml.Root.Elements("Animation"))
            {
                var animation = new List<Frame>();
                foreach (var frameNode in animationNode.Elements("Frame"))
                {
                    animation.Add(new Frame(BitmapImage, new Int32Rect(Width * (int)frameNode.Attribute("x"), Height * (int)frameNode.Attribute("y"), Width, Height), (int)frameNode.Attribute("time")));
                }
                _animations.Add(_animation = (string)animationNode.Attribute("name"), animation);
            }

            AnimationThread.Instance.Update += FrameUpate;
        }
Пример #2
0
 /// <summary>
 /// Creates a new sprite
 /// </summary>
 /// <param name="bitmapReference">The backing bitmap reference</param>
 public Sprite(BitmapReference bitmapReference)
     : base(bitmapReference)
 {
     Velocity = new Coordinate();
     Update = (unused, dt) => Location.Add(Velocity, dt);
 }
Пример #3
0
 /// <summary>
 /// Creates a new bitmap
 /// </summary>
 /// <param name="bitmapRef">The backing bitmap reference</param>
 public Bitmap(BitmapReference bitmapRef)
 {
     _ref = bitmapRef;
     Location = new Coordinate();
     _rect = new Rect(0, 0, Width, Height);
 }