GonerBits
Member
(I'm a total beginner to this, and this is my first time posting to here, so sorry if the formatting / code is kind of messy... I don't know what i'm doing haha)
I'm trying to make a text box system that allows for shaking text and changing text colors (preferably in a gradient) kind of like how you see in some RPGs.
I've been trying to study the ways a lot of people do this kind of effect and here's what I've come up with so far...
In order to change colors / make each letter shake individually, I know I have to draw each letter as a separate string... My problem here is that every time it draws a letter, the one before it disappears. I need to find a way to keep every previous letter on the screen without just using string_copy and making it into one string, but I'm not sure how...
It seems almost like I might need a "draw_text_color" function for every single letter of a string, but I'm not sure how I would implement something like that exactly.
Then in addition it needs to make sure each string stores its original attributes (color, shakiness etc) so that when I change the color only the letters AFTER the tag change, rather than all the letters at once.
Any help would be greatly appreciated...
I'm trying to make a text box system that allows for shaking text and changing text colors (preferably in a gradient) kind of like how you see in some RPGs.
I've been trying to study the ways a lot of people do this kind of effect and here's what I've come up with so far...
Code:
//CREATE EVENT
//Text pages
text[0] = "This is page 0!"
text[1] = "Annd this is page 1..."
page = 0
page_total = array_length_1d(text)
//Speed of drawing each character
charspd = 12
char = 1
alarm[0] = charspd
//Where to draw text
text_xstart = 40
text_ystart = 40
text_x = text_xstart
text_y = text_ystart
//Gradient colors
color1 = c_white
color2 = c_white
//Used for shaking
intensity = 0;
Code:
//DRAW GUI EVENT
draw_set_font(font)
//Set up shaking
shake_x = random_range(-intensity,intensity)
shake_y = random_range(-intensity,intensity)
//Get one letter
currletter = string_char_at(text[page],char)
nextletter = string_char_at(text[page],char+1)
char_width = string_width(currletter)
//Draw one letter
draw_text_color(text_x+shake_x,text_y+shake_y,currletter,color1,color1,color2,color2,1)
Code:
//ALARM 0
if char < string_length(text[page]) {
//Play sound
if currletter != " " {
audio_play_sound(snd_text,5,false)
}
//Change color when the tag comes up
if nextletter = "&" {
text[page] = string_delete(text[page],char,1)
//(Example of changing text properties... making it blue and shaky, changing the speed)
color2 = c_blue
intensity = 1
charspd = 20
}
//Go to next letter / position
char ++
text_x += char_width
alarm[0] = charspd
}
Code:
//Key press - Z
//Go to next page
if page < page_total {
page += 1
char = 1;
text_x = text_xstart
alarm[0] = charspd
}
It seems almost like I might need a "draw_text_color" function for every single letter of a string, but I'm not sure how I would implement something like that exactly.
Then in addition it needs to make sure each string stores its original attributes (color, shakiness etc) so that when I change the color only the letters AFTER the tag change, rather than all the letters at once.
Any help would be greatly appreciated...