• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [solved]change text colour when switching in menu

S

SonicTheHedgehog+123

Guest
I made a menu based on the menu video from shaun spalding. And I want to know how I can make the color of the text change if I am scrolling up or down(like in Undertale). So the selected word should change its color.
Open for help:p
 

Slyddar

Member
Would help to show the code for the draw event, but essentially however you are drawing the code that highlights the selection, you need an if/else option when drawing the text, which will use a draw_text_color() for both if and else, but one has a different colour set.
 
S

SonicTheHedgehog+123

Guest
Code:
//Draw Event
draw_set_halign(fa_left);
draw_set_valign(fa_middle);
draw_set_font(fnt_options);
draw_set_color(c_yellow);
var m; 
for (m = 0; m < array_length_1d(menu); m+= 1) 
{
  draw_text(x + space, y + (m * space),string(menu[m]))
}
draw_sprite(sprite_index, 0, x+ 16, y + mpos * space);
 

Slyddar

Member
Ok, I've taken a look at the video. The position is determined by mpos, so you could just change the color if mpos equals the for loop variable, m.
Code:
var col1 = c_yellow, col2 = c_white;
for (m = 0; m < array_length_1d(menu); m+= 1)
{
  if mpos == m draw_text_colour(x + space, y + (m * space), string(menu[m]), col1, col1, col1, col1, 1);
  else draw_text_colour(x + space, y + (m * space), string(menu[m]), col2, col2, col2, col2, 1);
}
Just for future reference, it helps us help you if you post the relevant code, so in this instance, the create, step and draw events. Saves us hunting for answers to give you answers, so you'll get help quicker.
 
Last edited:
S

SonicTheHedgehog+123

Guest
Thank you so much It WORKS!!!:D The only problem I got was that the GML couldnt read colour so I changed it to color.
I will put up the code next time I forgot it unfortunately. Sorry for making you problems.

Code:
//Draw Event
draw_set_halign(fa_left);
draw_set_valign(fa_middle);
draw_set_font(fnt_options);
var col1 = c_yellow, col2 = c_orange;
for (m = 0; m < array_length_1d(menu); m+= 1)
{
  if mpos == m draw_text_color(x + space, y + (m * space), string(menu[m]), col1, col1, col1, col1, 1);
  else draw_text_color(x + space, y + (m * space), string(menu[m]), col2, col2, col2, col2, 1);
}
draw_sprite(sprite_index, 0, x+ 16, y + mpos * space);
 
Top