Good evening to all AGSer !!!
Since there is not a section below the beginning area, I will post it here.
I would like to ask you if there is a way to choose a single char from a label text and being able to change its single color.
Example :
String text = "This is a String text";
I would love to get all the 't' or all the 'i' to be in a different color in that text.
Any of you know the right approach to use to get this to work ?
Grazie mille in advance.
The only way to do this is to compose a DynamicSprite using .DrawString(), then show that in place of the label, for instance by drawing the result onto the GUI's background image.
Hi Khris, is a glad to hear from you.
Thanks so much for suggesting the best approach to do something like this.
Your help was very greatly appreciated.
I meant to add a new parameter or two in my function, which can optionally change color for that char(in that specific text).
But I find difficulties to execute your idea in my script.
I wish I could show you and I hope you can help me again.
function _Say (this Character*, String txt, int speed, int color)
{
String text = GetTranslation(txt);
if (!color) color = chars_setup[this.ID].SpeechColor;
lblboard.TextColor = color;
// display char
String temp = "";
int text_length = text.Length;
int i = 0;
char current_char;
bool abort = false;
bool speaking = false;
while (i < text_length && !abort)
{
current_char = text.Chars[i];
temp = temp.AppendChar(current_char);
lblboard.Text = temp;
if (current_char == eKeyPeriod)
{
// do stuff
speaking = false;
}
else if (!speaking)
{
// do stuff
speaking = true;
}
abort = WaitMouseKey(6);
i++;
}
lblboard.Text = text;
// do stuff
if (abort)
WaitMouseKey(2 * (text_length - i) + 50);
else
WaitMouseKey(50);
}
I had to start by doing something like so :
// outside
DynamicSprite*text_box;
function game_start()
{
text_box = DynamicSprite.Create(gSpeechbox.Width, gSpeechbox.Height); // ?
}
Then I should write something like this but I can't figure it out how can I make this to work inside my function..
DrawingSurface*sur = text_box.GetDrawingSurface();
sur.DrawingColor = 14;
sur.DrawString(0, 0, Game.NormalFont, "%s", text); // text regarding the one inside the function...
gSpeechbox.BackgroundGraphic = text_box.Graphic;
sur.Release();
Could you describe *how exactly* the code fails?
Hi Khris, I am sorry for the late reply.
I had to change some things inside the function to make sure that your idea worked well.
I would like to thank you for your help because it was useful.
Especially use the DrawingSurface String and land the result in the background of the gui.
Bravo, Grazie mille :)