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

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

            this.region = region;
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 7
0
 //================================================================
 //Constructors
 //================================================================
 public AnimatedImage(Vector2 position, int time, TextureRegion[] regions)
     : base(position)
 {
     this.regions = regions;
     animation = new Animator(time, regions.Length);
 }
Exemplo n.º 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);
 }
Exemplo n.º 9
0
 public void SetTexture(TextureRegion region)
 {
     this.region = region;
 }
Exemplo n.º 10
0
 public ViewBackground(TextureRegion region, Vector2 position)
 {
     this.region = region;
     Position = position;
 }
Exemplo n.º 11
0
 //================================================================
 //Getter and Setter
 //================================================================
 public void SetBackground(TextureRegion region)
 {
     background.SetTexture(region);
 }
Exemplo n.º 12
0
 //================================================================
 //Constructors
 //================================================================
 public Button(Vector2 pos, TextureRegion region)
     : base(pos)
 {
     regions = new TextureRegion[1];
     regions[0] = region;
 }