Delta Engine
»
Support
»
Rendering
»
Font Color does not change
Joined: 1/17/2012(UTC) Posts: 1
|
If I try to change the color of a font, the color remains unchanged until anything else is changed (e.g. text or design). Code:
public static void ChangeTextColor()
{
string colorText = "Default text";
Font changeColorFont = Font.Default;
changeColorFont.TextColor = Color.Teal;
Application.Start(delegate
{
if (Input.GetState(InputButton.Space) == InputState.Pressed)
{
//colorText = "Changed color";
changeColorFont.TextColor = Color.Random;
}
changeColorFont.Draw(
colorText, Rectangle.FromCenter(new Point(0.5f, 0.5f), 0.5f));
});
}
|
|
|
|
Joined: 8/22/2011(UTC) Posts: 170 Location: Moscow
Thanks: 3 times Was thanked: 2 time(s) in 2 post(s)
|
Originally Posted by: Arne  If I try to change the color of a font, the color remains unchanged until anything else is changed (e.g. text or design). Code:
public static void ChangeTextColor()
{
string colorText = "Default text";
Font changeColorFont = Font.Default;
changeColorFont.TextColor = Color.Teal;
Application.Start(delegate
{
if (Input.GetState(InputButton.Space) == InputState.Pressed)
{
//colorText = "Changed color";
changeColorFont.TextColor = Color.Random;
}
changeColorFont.Draw(
colorText, Rectangle.FromCenter(new Point(0.5f, 0.5f), 0.5f));
});
}
My fast fix. Maybe it's wrong, but work Add new metod to Delta.Rendering.Basics.Fonts.Font Code:
#region ChangeColor (Public)
/// <summary>
/// ChangeColor Fix metod.
/// </summary>
/// <param name="color">Color</param>
public void ChangeColor(Color color)
{
TextColor = color;
if (glyphCache != null)
{
glyphCache.Clear();
}
}
#endregion
and in test use "changeColorFont.ChangeColor(Color.Random);" Code:[Test]
public static void ChangeTextColor()
{
string colorText = "Default text";
Font changeColorFont = Font.Default.Clone();
changeColorFont.TextColor = Color.Red;
Application.Start(delegate
{
changeColorFont.TextColor = Color.Random;
if (Time.CheckEvery(0.1f))
{
changeColorFont.ChangeColor(Color.Random);
}
changeColorFont.Draw(
colorText, Rectangle.FromCenter(new Point(0.5f, 0.5f), 0.5f));
});
}
Edited by user Wednesday, January 25, 2012 10:37:49 PM(UTC)
| Reason: Not specified |
Russian game developer. Давайте делать игры в команде. Идет набор. |
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
Thanks for the bug report, this seems to be an issue. We also wanted to change the way TextColors are changed (make them readonly). This will probably confuse some people, but make it much more clear that each instance of a font needs to be managed separately. In your example it would mean instead of: Code:
Font changeColorFont = Font.Default;
changeColorFont.TextColor = Color.Teal;
Just do: Code:
Font changeColorFont = Font.Default.Clone(Color.Teal);
But this will be fixed in the next nightly release nonetheless.
|
|
|
|
Delta Engine
»
Support
»
Rendering
»
Font Color does not change
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.