示例#1
0
        public SpriteFont(string _TextureFileName, string _MetricsFileName)
        {
            spritefont = new TextureGPU(_TextureFileName);

            XElement file = XElement.Load(_MetricsFileName);

            foreach (XElement element in file.Elements("character"))
            {
                char charindex = (char)byte.Parse(element.Attribute("key").Value);
                CharBounds chr = new CharBounds();
                int x = int.Parse(((string)element.Element("x").Value).Replace(",", "."));
                int y = int.Parse(((string)element.Element("y").Value).Replace(",", "."));
                int width = int.Parse(((string)element.Element("width").Value).Replace(",", "."));
                int height = int.Parse(((string)element.Element("height").Value).Replace(",", "."));
                chr.Pos = new Float2((float)x, (float)y);
                chr.Pos.X /= (float)spritefont.Size.X;
                chr.Pos.Y /= (float)spritefont.Size.Y;
                chr.Size = new Float2((float)width, (float)height);
                chr.Size.X /= (float)spritefont.Size.X;
                chr.Size.Y /= (float)spritefont.Size.Y;
                bounds.Add(charindex, chr);
            }
        }
示例#2
0
 public void SetParameter(string _FieldName, TextureGPU _Texture)
 {
     shader.Parameters[_FieldName].SetValue(_Texture.texture);
 }