示例#1
0
 //================================================================
 //Constructors
 //================================================================
 public Image(Vector2 position, TextureRegion region)
     : base(position)
 {
     this.region = region;
     Width = region.Bounds.Width;
     Height = region.Bounds.Height;
 }
示例#2
0
 //================================================================
 //Constructors
 //================================================================
 public CheckButton(Vector2 pos, TextureRegion general, TextureRegion press)
     : base(pos)
 {
     regions = new TextureRegion[2];
     regions[0] = general;
     regions[1] = press;
 }
示例#3
0
        //================================================================
        //Constructors
        //================================================================
        public SingleSprite(Vector2 postion, TextureRegion region)
            : base(postion)
        {
            this.region = region;

            Width = region.Bounds.Width;
            Height = region.Bounds.Height;
        }
示例#4
0
        public Particle(Vector2 pos, TextureRegion region)
            : base(pos)
        {
            if (region == null)
            {
                throw new Exception("null region particle");
            }

            this.region = region;
        }
示例#5
0
        public void LoadContent(string fileName)
        {
            regions = new Dictionary<string, TextureRegion>();

            XDocument xDocument = XDocument.Load(fileName);

            XElement imagePath = xDocument.Element("TextureAtlas");

            string name = imagePath.Attribute("imagePath").Value;
            Image = name.Split('.')[0];

            foreach (var sprite in xDocument.Descendants("sprite"))
            {
                TextureRegion region = new TextureRegion();

                int x = Convert.ToInt16(sprite.Attribute("x").Value);
                int y = Convert.ToInt16(sprite.Attribute("y").Value);
                int w = Convert.ToInt16(sprite.Attribute("w").Value);
                int h = Convert.ToInt16(sprite.Attribute("h").Value);

                int oY = sprite.Attribute("oY") == null ? 0 : Convert.ToInt16(sprite.Attribute("oY").Value);
                int oX = sprite.Attribute("oX") == null ? 0 : Convert.ToInt16(sprite.Attribute("oX").Value);
                int oW = sprite.Attribute("oW") == null ? 0 : Convert.ToInt16(sprite.Attribute("oW").Value);
                int oH = sprite.Attribute("oH") == null ? 0 : Convert.ToInt16(sprite.Attribute("oH").Value);

                region.Bounds = new Rectangle(x, y, w, h);
                region.Rotated = sprite.Attribute("r") != null;

                region.OriginTopLeft = new Vector2(-oX, -oY);
                region.OriginCenter = new Vector2(((oW / 2.0f) - (oX)), ((oH / 2.0f) - (oY)));
                region.OriginBottomRight = new Vector2((oW - (oX)), (oH - (oY)));

                string regionName = sprite.Attribute("n").Value;
                regionName = regionName.Split('.')[0];

                regions[regionName] = region;
            }
        }
示例#6
0
        public TextureRegion DeepCopy()
        {
            TextureRegion result = new TextureRegion();

            result.Texture = Texture;
            result.Bounds = new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
            if (OriginTopLeft != null) {
                result.OriginTopLeft = new Vector2(OriginTopLeft.X, OriginTopLeft.Y);
            }

            if (OriginCenter != null)
            {
                result.OriginCenter = new Vector2(OriginCenter.X, OriginCenter.Y);
            }

            if (OriginBottomRight != null)
            {
                result.OriginBottomRight = new Vector2(OriginBottomRight.X, OriginBottomRight.Y);
            }
            result.Rotated = Rotated;

            return result;
        }
示例#7
0
 //================================================================
 //Constructors
 //================================================================
 public AnimatedImage(Vector2 position, int time, TextureRegion[] regions)
     : base(position)
 {
     this.regions = regions;
     animation = new Animator(time, regions.Length);
 }
示例#8
0
 public void SetTexture(Texture2D texture, int width, int height)
 {
     this.region = new TextureRegion();
     region.Texture = texture;
     region.Bounds = new Rectangle(0, 0, width, height);
 }
示例#9
0
 public void SetTexture(TextureRegion region)
 {
     this.region = region;
 }
示例#10
0
 public ViewBackground(TextureRegion region, Vector2 position)
 {
     this.region = region;
     Position = position;
 }
示例#11
0
 //================================================================
 //Getter and Setter
 //================================================================
 public void SetBackground(TextureRegion region)
 {
     background.SetTexture(region);
 }
示例#12
0
 //================================================================
 //Constructors
 //================================================================
 public Button(Vector2 pos, TextureRegion region)
     : base(pos)
 {
     regions = new TextureRegion[1];
     regions[0] = region;
 }