GameMaker: Studio

GameMaker: Studio

View Stats:
Text Box System
I need some help trying to make a Text Box System for a RPG game, something like earthbound is what i was thinking off. I would appreciate it if someone would help me or send a link to a video that helps explain how to do it.

Thank You :3
Last edited by Sappy Secretary; Mar 14, 2019 @ 2:18am
< >
Showing 1-2 of 2 comments
maras Mar 14, 2019 @ 6:41am 
There are tons of tutorials on the internet. Just google "game maker text box system" :P
The Winter Bud Mar 14, 2019 @ 9:04pm 
A very very simple text box to get you started on your journey. It centers the text inside a background box. It uses a maximum width to guide the box. There is no maximum length to the box so supplying a very long string will result in a very long text box. To widen the text box just increase the "width" variable to a desired width. You can increase or decrease the border size by increasing or decreasing the "border" value.


DrawTextBox(xx,yy,text, font, color, backcolor)
// assign arguments to variables var xx=argument0; // x/y location where you want to display textbox var yy=argument1; var text=argument2; // the text to be displayed var font=argument3; // the font to use var color=argument4; // the text color var backcolor=argument5; // the background color if(font_exists(font)) draw_set_font(font); // set font if it exists var width=300; // maximum width of the textbox var height=string_height_ext(text,-1,width); var w=width div 2+4; // used in centering background around text var h=height div 2+4; var border=2; // how many pixel border draw_set_halign(fa_center); // draw text centered both hor and vert draw_set_valign(fa_middle); // draw the background draw_rectangle_colour(xx-w-border, yy-h-border, xx+w+border, yy+h+border, color,color,color,color,false); draw_rectangle_colour(xx-w, yy-h, xx+w, yy+h, backcolor,backcolor,backcolor,backcolor,false); // draw the text draw_text_ext_colour(xx,yy,text,-1,width,color,color,color,color,1); // reset character alignment draw_set_halign(fa_left); draw_set_valign(fa_top);

How to use
mytext="This is the text I want to display. It's a simple message and full of words. It was long winded so as to display the fullness of the textbox."; DrawTextBox(x,y,mytext,fntTextbox,c_white,c_black);

EDIT - this is just a script that will draw a text box. To make it handy you might want to create an object to utilize the script

obj_textbox
create event
font=fntTextBox; // used by the textbox text=""; // empty text alarm[0]=150; // how long you want to display text (5 seconds)
alarm 0 event
instance_destroy(); // destroy ourselves when done
draw event
if(text!=""){ DrawText(x,y,text,font,c_white,c_black); }


Then all you have to do to use it is create the object where you want to show the box and give it it's text
var tb=instance_create(somex,somey,obj_textbox); // note somex and somey are where you want the textbox to show tb.text="This is the text to be displayed";

This is common domain. no need for credit. it was created years ago by many people and used by many as a basic idea or concept. Searching the internet will return similar results. It was written to help you understand how GML can be used to create simplistic displays. Tweaking the script is up to the understanding of the user and are encouraged to play around with it to shape it into something you can use.
Last edited by The Winter Bud; Mar 14, 2019 @ 9:31pm
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Mar 14, 2019 @ 2:18am
Posts: 2