Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline Arne  
#1 Posted : Wednesday, January 25, 2012 7:28:33 PM(UTC)
Arne

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));
			});
		}

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline bfox  
#2 Posted : Wednesday, January 25, 2012 10:36:50 PM(UTC)
bfox

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 Go to Quoted Post
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 ThumpUp
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.
Давайте делать игры в команде. Идет набор.
Offline Benjamin  
#3 Posted : Wednesday, January 25, 2012 10:59:39 PM(UTC)
Benjamin

Medals: Admin

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.
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
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.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.051 seconds.