Hi I made a text actor, and the thing I want is when the user clicks on the actor, I need the text's color/font to change
Is there a way to make it done by script maybe ?
lcl wrote:Hi Xpoint! Welcome to the Game Editor forum! I hope you like it here.
The only way to change a text actor's color through script is to adjust the actor's r (= red), g (= green) and b (=blue) variables. Each of those variables can have values between 0 and 255, and every actor in Game Editor has it's own r, g and b values. By changing those values you can change the coloring of any actor, including text actors. But note that if you want to be able to use r, g and b to color your text actor with any color you want, the text actor's initial font should be white, as that's when changing r, g and b can have maximum effect on the color of the text. Same goes for other actors - recoloring works best if the actor's animation is white or drawn in grayscale.
But there is also a different way to change a text actor's color in-game. You can use the Set Text -action in any event, like the mosue button down event, as you suggested. Set Text allows you to change the text actor's text, font and color.
I hope this helps! And if there's something you don't understand or something else you'd like to ask, please do, I'm willing to help you.
lcl wrote:Why exactly do you have to have the "textActor->textNumber = 0;" line there? What do you need it for? The problem you are facing is caused by you trying to use textNumber and text at the same time, you're supposed to only use one of those at a time for a single actor. (Though I'd generally advise against using textNumber at all.)
Xpoint wrote:lcl wrote:Why exactly do you have to have the "textActor->textNumber = 0;" line there? What do you need it for? The problem you are facing is caused by you trying to use textNumber and text at the same time, you're supposed to only use one of those at a time for a single actor. (Though I'd generally advise against using textNumber at all.)
I am using it for Sudoku game, I want when the user clicks on the new game button I want to reset the textNumber of my text actors and to zero and I want not to show the 0 symbol instead I want to show the dash "-" symbol
sprintf(textActor->text, "%i", textActor->num);
//ABOUT THE CODE:
//sprintf is almost the same as strcpy, it just allows you to format the text.
//The part in quotes is the string that will be printed to textActor->text
//and the %i means that in that place in the string there will be an integer number.
//The last argument is the value of the integer to be placed where the %i is, so,
//in this case the value will be the value of textActor->num.
//EXAMPLE: in this example the textActor->num is 3
//The value of textActor->num is placed to where the %i is, so the string becomes "3".
//The resulting string will be printed to textActor->text, so now it will also be "3".
//And here's what the text actor will now show on screen: 3
textActor->num = 5; //Replace 5 with the value you want to assign to the actor
strcpy(textActor->text, "-");
lcl wrote:Sorry for taking so long to answer, I'm on a vacation abroad, and accessing internet is not so easy here.Xpoint wrote:lcl wrote:Why exactly do you have to have the "textActor->textNumber = 0;" line there? What do you need it for? The problem you are facing is caused by you trying to use textNumber and text at the same time, you're supposed to only use one of those at a time for a single actor. (Though I'd generally advise against using textNumber at all.)
I am using it for Sudoku game, I want when the user clicks on the new game button I want to reset the textNumber of my text actors and to zero and I want not to show the 0 symbol instead I want to show the dash "-" symbol
Oh, I see. But as I said, I'd still advise against using textNumber, especially because I guess you're going to have to perform some kind of checks on those numbers to see if the Sudoku grid is filled correctly. The textNumber variable should not be used as a way of storing values, it's meant only to be used as a way of displaying numbers (and is actually not that good even for that).
Here's what I'd suggest you to do:
- Create a new variable called num (for number, you can of course use some other name too), and make it an Integer Actor variable. Now every actor in the game has a new actor variable called num that can store integer numbers.
- Now you can make your text actors show their number by using a code like this (all text after the first line is comments about the code, not actual code):
- Code: Select all
sprintf(textActor->text, "%i", textActor->num);
//ABOUT THE CODE:
//sprintf is almost the same as strcpy, it just allows you to format the text.
//The part in quotes is the string that will be printed to textActor->text
//and the %i means that in that place in the string there will be an integer number.
//The last argument is the value of the integer to be placed where the %i is, so,
//in this case the value will be the value of textActor->num.
//EXAMPLE: in this example the textActor->num is 3
//The value of textActor->num is placed to where the %i is, so the string becomes "3".
//The resulting string will be printed to textActor->text, so now it will also be "3".
//And here's what the text actor will now show on screen: 3- And if you want to change the text actor's num value, just do this:
- Code: Select all
textActor->num = 5; //Replace 5 with the value you want to assign to the actor
- And for showing the "-" symbol, just use this code:
- Code: Select all
strcpy(textActor->text, "-");
I hope this helps. However, if you still have questions, just ask and I'll do my best to help you.
Xpoint wrote:thanks a lot that worked well.
Sorry I forget to thank you before but the pressure of work and collage made me forget.
Users browsing this forum: No registered users and 1 guest