STEAM GROUP
Developers Zoo Dev-Zoo
STEAM GROUP
Developers Zoo Dev-Zoo
2
IN-GAME
31
ONLINE
Founded
2 September, 2012
Language
English
Mr Black 5 Sep, 2016 @ 9:25am
How would a text box be made in GameMaker?
Trying to make text boxes WITH text in them but cant figure it out. What would the bes way be?:2015holly::SBpanda::ToxicTin:
< >
Showing 1-1 of 1 comments
James 5 Sep, 2016 @ 11:39am 
Here is one that I used for the Intro/Outro of ENYO:

Information about object: obj_ui_storyText

//====
Create Event:
execute code:
//====

typed_letters = 0; //for typewriter effect (one letter at a time)
i=0
show=true

text[0,0]='1st part of text'
text[0,1]='2nd part of text'
text[0,2]='3rd part of text'
text[0,3]=''
text[1,1]='another 1st part of text'
text[1,2]='etc...'
text[1,3]=''
//make the last msg be equal to '' to end the messages

txtPart = 0;
txtSel = 0; //when I create this object I set this var to the textblocks I want to show (-> with(instance create(0,0,obj_ui_storyText) { txtSel = 1; } <-that is how I create it)

nxtBtnX = 400; //this is the position of the 'NEXT' sprite
nxtBtnY = 200;
nxtBtnAlpha = 0;

//====
Alarm Event for alarm 0:
execute code:
//====

if (typed_letters < string_length(text[txtSel,i])) //this loops untill all letters are typed
{
alarm[0] = type_speed*room_speed;
typed_letters++;
audio_play_sound(snd_ui_button_tick,2,false);
}
else alarm[1] = 4*room_speed; //when its done it triggers alarm[1] after 4 secconds

//====
Alarm Event for alarm 1:
execute code:
//====

typed_letters = 0;
show=false;
instance_destroy(); //this destroys the textbox


//====
Step Event:
execute code:
//====

if (nxtBtnAlpha < 1) //this just fades in the 'NEXT' sprite
{
nxtBtnAlpha += 0.025;
}

//here comes the control for going to the next part of the text
var kContinue;
kContinue = keyboard_check_pressed(vk_space);
if (kContinue)
{
typed_letters = 0;
if (text[txtSel,i]!=''){i+=1;show=true; nxtBtnAlpha = 0;}
if (text[txtSel,i]='')
{
show=false;
}

}


//====
Draw Event: //If you want to use a box like this with a moving view (ingame) then better use a drawGUI event...
execute code:
//====


draw_sprite_ext(spr_ui_txtBoxNextIcon, 0, nxtBtnX, nxtBtnY, 1,1,0,c_white, nxtBtnAlpha); //draws the 'NEXT' sprite
draw_text_ext(x, y, string_copy(text[txtPart,txtSel], 0, typed_letters),14,390); //draws the text



================EOF

Hope that helps a little?!
< >
Showing 1-1 of 1 comments
Per page: 1530 50