Exemple #1
0
        internal Layer(World world, System.Xml.XmlElement la, int tilewidth, int tileheight, SFML.Graphics.Image image)
        {
            Name            = la.GetAttributeString("name");
            width           = la.GetAttributeInt("width");
            height          = la.GetAttributeInt("height");
            this.tilewidth  = tilewidth;
            this.tileheight = tileheight;

            tiles = new int[width * height];

            var data  = la.FirstElement("data");
            int index = 0;

            foreach (var tile in data.ElementsNamed("tile"))
            {
                var gid = tile.GetAttributeInt("gid");
                tiles[index] = gid;
                ++index;
            }

            foreach (var o in ObjectDatas)
            {
                if (o.gid != 0)
                {
                    var sp = Tiles.CreateSprite(image, o.gid, tilewidth, tileheight);
                    sp.Position = o.pos;
                    sprites.Add(sp);
                }
            }
        }