public void TextureRegion2D_Specified_Test() { var graphicsDevice = TestHelper.CreateGraphicsDevice(); var texture = new Texture2D(graphicsDevice, 100, 200); var textureRegion = new TextureRegion2D(texture, 10, 20, 30, 40); Assert.AreSame(texture, textureRegion.Texture); Assert.AreEqual(10, textureRegion.X); Assert.AreEqual(20, textureRegion.Y); Assert.AreEqual(30, textureRegion.Width); Assert.AreEqual(40, textureRegion.Height); Assert.IsNull(textureRegion.Tag); }
private static Dictionary<char, BitmapFontRegion> BuildCharacterMap(Texture2D[] textures, BitmapFontFile fontFile) { var characterMap = new Dictionary<char, BitmapFontRegion>(); foreach (var fontChar in fontFile.Chars) { var pageIndex = fontChar.Page; var character = (char)fontChar.ID; var texture = textures[pageIndex]; var region = new TextureRegion2D(texture, fontChar.X, fontChar.Y, fontChar.Width, fontChar.Height); var fontRegion = new BitmapFontRegion(region, fontChar); characterMap.Add(character, fontRegion); } return characterMap; }
public BitmapFontRegion(TextureRegion2D textureRegion, BitmapFontChar fontCharacter) { TextureRegion = textureRegion; FontCharacter = fontCharacter; }
public static void Draw(this SpriteBatch spriteBatch, TextureRegion2D textureRegion, Vector2 position, Color color) { spriteBatch.Draw(textureRegion.Texture, position, textureRegion.Bounds, color); }
public static void Draw(this SpriteBatch spriteBatch, TextureRegion2D textureRegion, Rectangle destinationRectangle, Color color) { spriteBatch.Draw(textureRegion.Texture, destinationRectangle, textureRegion.Bounds, color); }