Replies to topics in this forum are held to a high standard. Reviews must have a critique or suggestion for use to be approved. Read the rules here.
I put together a simple textbox engine that actually works pretty well. It creates a textbox with your text, in the center of the screen/view.
Title:TextBox Tutorial
Download: link - Host: box.net
No registered functions used.
Filetype: gmk file (about 30 kb)
The script below works in GM7.0 and GM6.1 as far as I know!
Create a new script, and call it "scr_textbox" - Place the following code in the new script:
//Argument0=Title
//Argument1=Text
//Argument2=Displayed textbox or not
//Argument3=Background Colour
//Argument4=Border Colour
//Argument5=Background Alpha
//Argument6=Other Messages/Continue Button/Whatever
contkey=argument2
if contkey=false {exit;}
title=argument0
text=argument1
col1=argument3
col2=argument4
alpha=argument5
finish=argument6
centerx=view_xview+view_wview/2
centery=view_yview+view_hview/2
draw_set_color(col1)
draw_set_alpha(alpha)
draw_set_font(fn_message_main)
if string_width(text)>string_width(finish)
{
draw_rectangle(centerx-string_width(text)/2-20,centery-string_height(text)/2-30,centerx+string_width(text)/2+20,centery+string_height(text)/2+30,false)
draw_set_color(col2)
draw_set_alpha(1)
draw_rectangle(centerx-string_width(text)/2-20,centery-string_height(text)/2-30,centerx+string_width(text)/2+20,centery+string_height(text)/2+30,true)
}
else
{
draw_rectangle(centerx-string_width(finish)/2-20,centery-string_height(finish)/2-30,centerx+string_width(finish)/2+20,centery+string_height(finish)/2+30,false)
draw_set_color(col2)
draw_set_alpha(1)
draw_rectangle(centerx-string_width(finish)/2-20,centery-string_height(finish)/2-30,centerx+string_width(finish)/2+20,centery+string_height(finish)/2+30,true)
}
draw_set_halign(fa_center)
draw_set_font(fn_message_title)
draw_set_color(col2)
draw_text(centerx,centery-string_height(text)/2-15,title)
draw_set_halign(fa_left)
draw_set_font(fn_message_main)
draw_text(centerx-string_width(text)/2,centery-string_height(text)/2,text)
draw_set_halign(fa_center)
draw_set_font(fn_message_end)
draw_text(centerx,centery+string_height(text)/2+5,finish)Then, create 3 fonts of your choosing, naming them:
fn_message_title
fn_message_main
fn_message_end
Then, create an object, and put this in the create event:
i=0 show[i]=false text[0]='This is part 1' text[1]='This is part 2' text[2]='This is part 3' text[3]='This is part 4' text[4]='etc...' text[5]='etc...' text[6]='' //You can have as many as you like, just make the last one be equal to ''Put this in the keyboard_pressed event that will be the continue key:
if show[i]=true
{
if text[i]!=''{i+=1;}
if text[i]!=''{show[i]=true} else {show[i]=false}
show[i-1]=false
}Put this in the draw event:scr_textbox('Title!',text[i],show[i],c_white,c_black,0.8,'Click Enter to Continue!')Once you have that all set up, just set show[0]=true when you want the textbox to start. (You could just set it to true in the create event).
If used, you don't need to give credit.
-Drazzke











