public TextureMap LoadTexture(string key) { if (key.Contains(".")) { TextureMap textureMap = new TextureMap(); textureMap.Bitmap = LoadBitmapByKey(key); return(textureMap); } else { if (atlasXml == null) { LoadAtlasXml(); } var element = atlasXml.Root.Elements("sprite").FirstOrDefault(x => x.Attribute("n").Value == key); if (element != null) { if (atlas == null) { LoadAtlasBitmap(); } TextureMap textureMap = new TextureMap(); textureMap.Bitmap = atlas; int x = int.Parse(element.Attribute("x").Value); int y = int.Parse(element.Attribute("y").Value); int w = int.Parse(element.Attribute("w").Value); int h = int.Parse(element.Attribute("h").Value); textureMap.SourceRectangle = new RectangleF(x, y, w, h); return(textureMap); } } throw new Exception("Could not find texture. Key was: \"" + key + "\""); }
public void AddTextureMap(TextureMap textureMap) { if (Bitmap != textureMap.Bitmap) { throw new Exception("Bitmap must be the same."); } this.SourceRectangles.Add(textureMap.SourceRectangle.Value); }
public void LoadContent() { textureSelected = contentProvider.LoadTexture("Selected"); }