/// <summary> /// Set the Texture that the Graphic is using (if it is using one.) /// </summary> /// <param name="atlasTexture">The AtlasTexture to use.</param> public void SetTexture(AtlasTexture atlasTexture) { Texture = atlasTexture.Texture; AtlasRegion = atlasTexture.Region; TextureRegion.Width = atlasTexture.Width; TextureRegion.Height = atlasTexture.Height; NeedsUpdate = true; }
/// <summary> /// Add another atlas to the collection of textures. Duplicate names will destroy this. /// </summary> /// <param name="source">The relative path to the data file. The png should be in the same directory.</param> public Atlas Add(string source) { var xml = new XmlDocument(); xml.Load(source); var atlas = xml.GetElementsByTagName("TextureAtlas"); var imagePath = Path.GetDirectoryName(source) + "/"; if (imagePath == "/") { imagePath = ""; } foreach (XmlElement a in xml.GetElementsByTagName("TextureAtlas")) { foreach (XmlElement e in xml.GetElementsByTagName("SubTexture")) { var name = e.AttributeString("name"); var uniqueName = true; foreach (var atest in subtextures.Values) { if (atest.Name == name) { uniqueName = false; break; } } if (uniqueName) { var atext = new AtlasTexture(); atext.X = e.AttributeInt("x"); atext.Y = e.AttributeInt("y"); atext.Width = e.AttributeInt("width"); atext.Height = e.AttributeInt("height"); atext.FrameHeight = e.AttributeInt("frameHeight", atext.Height); atext.FrameWidth = e.AttributeInt("frameWidth", atext.Width); atext.FrameX = e.AttributeInt("frameX", 0); atext.FrameY = e.AttributeInt("frameY", 0); atext.Name = name; atext.Source = imagePath + a.AttributeString("imagePath"); atext.Texture = new Texture(atext.Source); subtextures.Add(e.AttributeString("name"), atext); } } } return(this); }
/// <summary> /// Create a new Particle. /// </summary> /// <param name="x">The x position.</param> /// <param name="y">The y position.</param> /// <param name="texture"></param> /// <param name="width"></param> /// <param name="height"></param> public Particle(float x, float y, AtlasTexture texture, int width = 0, int height = 0) : base(x, y) { Image = new ImageSet(texture, width, height); }
/// <summary> /// Create a new Decals object using an AtlasTexture. /// </summary> /// <param name="texture"></param> public Decals(AtlasTexture texture) { SetTexture(texture); Initialize(); }