コード例 #1
0
        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 + "\"");
        }
コード例 #2
0
        public void AddTextureMap(TextureMap textureMap)
        {
            if (Bitmap != textureMap.Bitmap)
            {
                throw new Exception("Bitmap must be the same.");
            }

            this.SourceRectangles.Add(textureMap.SourceRectangle.Value);
        }
コード例 #3
0
 public void LoadContent()
 {
     textureSelected = contentProvider.LoadTexture("Selected");
 }