This project has scripts for drawing a textbox with some text.
Maintained by: gurpreetsinghmatharoo
They are to be used in the Draw GUI event.
This project comes with a basic example for testing the scripts. Run the game and hold SPACE for the text to appear.
Here are the main functions in this project:
Draws a textbox on the screen.
The [x, y] arguments are optional. If you don't fill in those arguments (or just fill undefined
), the textbox will automatically adjust its location at the bottom of the window.
draw_textbox("GitHub is cool!");
draw_textbox("and GameMaker too!", 0, 50);
Draws a textbox with a specified number of characters.
Use this function for a typing effect. The second argument specifies how many characters are drawn from the text.
The three arguments [x, y, speaker] are optional. [x, y] can take undefined
- it will be the same as not filling those arguments.
[speaker] is the ID of the speaker to use, and it's optional. Read more under the Speakers section.
draw_textbox_char("Hello!", 4); //Will say "Hell"
draw_textbox_char("I'm saying this in a typing effect...", chars);
These are options that you can modify before drawing a textbox - usage is similar to using draw_set_color()
to change the color before drawing something in GML.
By default, a textbox will automatically adjust its size according the GUI layer's size. Using this function, you can change the size to use in textbox functions that come after this.
Use tb_reset_size()
after you're done drawing a differently-sized textbox.
draw_textbox("This is a full size textbox");
tb_set_size(64, 64);
draw_textbox("This textbox is smol");
tb_reset_size();
Changes the sprite used for the textboxes drawn after this function. By default, the scripts will use sTextbox
which comes with this project. Use tb_reset_sprite
to set the sprite to the default one.
The sprite must be square, can be any size. Must be a 3x3 grid.
tb_set_sprite(sNewTextbox, 1);
draw_textbox("Whoa, a new textbox!");
tb_reset_sprite();
Speakers are the people who will say the text in the textbox. They're not required, but in the draw_textbox_char()
function, you can specify a speaker.
A speaker needs an image and a name, and it will appear with the message.
This will create a new speaker with the specified name & image. Store the returned value in a variable.
spkDan = speaker_add("Dan", sDan, 0);
This will delete a speaker.
speaker_delete(spkDan);
Set whether or not to stretch the speakers' images to fit the textbox.
Default: true
Set whether or not to draw the speakers' images outside of the box. Note that stretching will not be applied if this is true.
Default: false
Set an offset for the speakers' images. The x and y values will be added to the position of the images when they're drawn.
Default: 0, 0