public Benchmark() { TextureLoader starRes = new TextureLoader(); starRes.LoadLocalImage("benchmark_object.png"); textures = new Texture[] { starRes.Texture }; // the container will hold all test objects _container = new Sprite(); AddChild(_container); EnterFrame += EnterFrameHandler; AddedToStage += AddedToStageHandler; }
private void ParseFontData(Stream fontTextureData, Stream fontXmlData) { if (fontTextureData == null || fontXmlData == null) { throw new InvalidOperationException("Font parsing requires texture and font XML to be set"); } TextureLoader texLoader = new TextureLoader(); GLTexture tex = texLoader.LoadFromStream(fontTextureData); _fontTexture = new SubTexture(tex); _chars = new Dictionary<int,BitmapChar>(); _helperImage = new Image(_fontTexture); XmlDocument xml = new XmlDocument(); xml.Load(fontXmlData); float scale = _fontTexture.Scale; ParseAndLoadChars(xml, scale); ParseAndLoadKerning(xml, scale); ParseAndLoadInfo(xml); ParseAndLoadCommon(xml); }
private Texture TextureReferencedByXmlData(TextureLoader textureLoader, Stream fontXmlData) { XmlDocument xml = new XmlDocument(); xml.Load(fontXmlData); Texture texture = null; XmlNodeList pageNodes = xml.GetElementsByTagName("page"); for (int i = 0; i < pageNodes.Count; i++) { XmlAttributeCollection attributes = pageNodes[i].Attributes; int id = Convert.ToInt32(attributes["id"]); if (id != 0) { throw new Exception("Bitmap fonts with multiple pages are not supported"); } string filename = attributes["file"].Value; string absolutePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Resources), filename); // NSBundle.MainBundle.BundlePath texture = textureLoader.LoadLocalImage(absolutePath); } if (texture == null) { throw new InvalidDataException("Font XML doesn't contain path to texture"); } return texture; }