Jump to content


Photo

Scrolling Text Below Image


  • Please log in to reply
20 replies to this topic

#1 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 02 May 2012 - 08:27 AM

So, I've been looking around at a lot of tutorials - and since I don't really understand GML, most are unhelpful. Any that provide GMK examples won't open on my version of Game Maker either - so I'm sort of stuck.

Anyway, I'm trying to make text appear under a talking character sprite that will appear in the middle of the screen and talk - the text should appear below this box. I'm not sure how to do this, and how to delete old text when I move on to a new line. Should I make this in a timeline?

Also, I want to fade out the background/pause the enemies as this little scene goes on - as they'll happen in the middle of gameplay - so how should I do that?

Sorry if i'm unclear, I'm pretty tired ;u;

Thanks for any help! :)
  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

  • GMC Member
  • 1558 posts
  • Version:GM:Studio

Posted 02 May 2012 - 09:50 AM

sorry but your pretty much going to have to look at gml to achieve this.

You are going to have to use variables or data structures holding the text in strings.

then you could write out the text like a typewriter(one character at a time) or other effects or just have it appear and then write a new line.

an alternative is to write it all to a surface(could also be a sprite if you didn't need to change the text easily) and then either jump it up a line or slide it up a line gradually as you read it in the box(or it is "said outloud")


as for the enemy freezing part, you should add a line of code checking for global.talking and if it is talking then dont let them do any of their movement/attacking code. but anyways, would someone talking in the middle of battle really stop someone coming up and hitting them! :P


you could achieve a visual effect like blacking out the background with enemies and such, and a reverse of that for when you entering to a conversation and out of one with a time line. but i would not do the text part with a timeline.

gml is pretty much the best way.
  • 0

#3 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 02 May 2012 - 04:50 PM

Jack Indie Box is pretty much right. The best way to do scrolling text boxes is with GML. Its plausible with drag & drop but it would be VERY difficult without sleep & while loops. If you want a GML script for it, I made a pretty good & easy to understand example a little bit ago.
//////////////////////////////////
//Lemon Pie's Scrolling Text Box//
//////////////////////////////////////////////////////////////////////////
//argument0 = Input text                                                //
//argument1 = black text(true) or white(false)                          //
//argument2 = Normal (false) or cutscene(true)                          //
//If "Cutscene" is true, it will draw a plain rectangle on the screen.  //
//The box will black if the text is white, or white if the text is black//
//argument0 should be a line of text enveloped in 2 quotation marks     //
//like this: "Hi There! I'm Lemon Pie, and I make games!"               //
//If you need a new line put # somewhere in your text like this:        //
//"You want a piece of me, huh?#YOU WANT A PIECE PUNK?!"                //
//If you need to add a variable into your string (the text)             //
//argument0 would look like this: "You have "+string(score)+" monies."  //
//This script will (more or less) pause the game while its running      //
//so you don't need to add any extra code to stop your characters! Yay! //
//////////////////////////////////////////////////////////////////////////

ti = argument0; //Input text
to = '';        //Output text
tn = 0;         //Text at
c = !argument1;  //color modifier

if argument2 = false //If you are not in "Cutscene" mode
{
    draw_background(back_TextBox,0,480-128) //Draws the text box.
    //You can make this your own background, or turn it into draw_sprite() w/ your text sprite.
}
else //if you are in 'Cutscene' mode
{
    draw_set_color(make_color_rgb(255*!c,255*!c,255*!c))    //makes the color black or white
    draw_rectangle(0,480-128,640,480,false) //Draws the text box
}

while string_length(to) < string_length(ti)
{
    tn += 1;                    //Sets the point where the text is at
    draw_set_font(fnt_Text)     //Sets the font to your Text font
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text(8,480-123,to);    //Draws the text
    screen_refresh();           //Refreshes the screen (so the text will appear)
    sleep(15);                  //Waits 15 milliseconds before iterating
}
draw_sprite(spr_Arrow,0,640-16,480-16)  //Draws an arrow sprite.
screen_refresh();   //Refreshes the screen
sleep(100);          //Waits for 1/10 of a second, keeps the text from continuing if Enter is held
while !keyboard_check(vk_enter) //Until the Enter key is pressed
{
    sleep(1);   //Waits 1 millisecond
}
screen_redraw();    //redraws the screen, stopping certain graphical glitches

Also, for GMKs you can't use, use LateralGM to backport it to the version you need. You really should upgrade to GM8 or 8.1 though.
  • 0

#4 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 02 May 2012 - 09:43 PM

Thanks both of you! Lemonpie, I was wondering where I would put all of this code? Should I make a new object that like - when the character runs into it - it triggers all of this dialogue?

I've never used timelines either - so I'm not sure how to do that. Thanks. :)

--

Oh wait -- I think I see...hang on I'm gonna try and figure out cutscene mode...:D

--

I don't understand "Back_Textbox" or whatever? I'm not familiar with code - so I don't know where I'm defining these variables ;u;

Edited by Minishcactus, 02 May 2012 - 10:00 PM.

  • 0

#5 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 02 May 2012 - 10:08 PM

It is a script. Put it all in one script (not a code snippet) & rename the script to scr_DrawMessage or something like that & after adding your spirtes & background names you can activate it at any time by calling the script.
back_TextBox is a background that is drawn as the textbox.
'cutscene' mode makes the text box black or white depending on the text color value.

An execution of that code would go:
scr_DrawMessage('Your Text goes here!')
and that would draw your text w/ a normal text box.

for cutscenes you can do
scr_DrawMessage('Texty mc testin text', false,true)
and that would draw a black text box (for a cutscene or something) with white text.

http://sandbox.yoyog...s/3615/download heres a demonstration of it.

Edited by Lemon Pie, 02 May 2012 - 10:11 PM.

  • 0

#6 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 02 May 2012 - 10:13 PM

Oh, okay, I see.

So - the way my text is going to work is that - depending on the scene or what's being said - he'll have a different expression.

I see where it says to change the background to a sprite, or whatever - how can I make it so, depending on the type of message I want, the sprite is different?
  • 0

#7 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 02 May 2012 - 10:24 PM

like this?
Posted Image
  • 0

#8 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 02 May 2012 - 10:37 PM

like this?
Posted Image



Yeah - but the sprites are animated

Kinda like this: http://www.youtube.c...h?v=azByfQ6nP2o
  • 0

#9 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 03 May 2012 - 12:18 AM

alright fixed. argument1 is now the name of your face sprite. Each face sprite should have an open or closed mouth, with the second subimage being an open mouth, & you'll need a different sprite for each expression.
ti = argument0; //Input text
to = '';        //Output text
tn = 0;         //Text at
c = !argument2;  //color modifier
face = argument1; //face sprite. 
//Give each expression its own mouth open & closed for vowels.
//Open mouth should be the second subimage

io_clear(); //clears the pressed status any previously pressed buttons & input devices for this step
if argument3 = false //If you are not in "Cutscene" mode
{
    draw_background(back_TextBox,0,480-128) //Draws the text box.
    //You can make this your own background
}
else //if you are in 'Cutscene' mode
{
    draw_set_color(make_color_rgb(255*!c,255*!c,255*!c))    //makes the color black or white
    draw_rectangle(0,480-128,640,480,false) //Draws the "text box"
}

while string_length(to) < string_length(ti)
{
    tn += 1;   //Sets the point where the text is at
    if sprite_exists(face) //if you have a face sprite.
    {
        if string_char_at(ti,tn)= 'A' //if there is a vowel at the current piece of text
        ||string_char_at(ti,tn) = 'E'
        ||string_char_at(ti,tn) = 'I'
        ||string_char_at(ti,tn) = 'O'
        ||string_char_at(ti,tn) = 'U'
        ||string_char_at(ti,tn) = 'Y'
        ||string_char_at(ti,tn) = 'a'
        ||string_char_at(ti,tn) = 'e'
        ||string_char_at(ti,tn) = 'i'
        ||string_char_at(ti,tn) = 'o'
        ||string_char_at(ti,tn) = 'y'
        {
            f=1; //mouth will be open
        }
        else f=0; //mouth is closed
        draw_sprite(face,f,8,480-123)
    }
    draw_set_font(fnt_Text)     //Sets the font to your Text font
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(50+8,480-123,to,15,-1);    //Draws the text
    screen_refresh();           //Refreshes the screen (so the text will appear)
    sleep(50);                  //Waits 25 milliseconds before iterating
}
draw_set_color(c_aqua) //sets the color to light blue
draw_triangle(640-2,480-20,640-20,480-20,640-12,480-2,false) //draws a triangle
screen_refresh();   //Refreshes the screen
while !keyboard_check(vk_enter) //Until the Enter key is pressed
{
    sleep(1);   //Waits 1 millisecond
}
screen_redraw();    //redraws the screen, stopping certain graphical glitches

basically:
scr_DrawText('Your Text belongs right here', spr_FaceSprite, false, false)

argument0 is your string,
argument1 is your face sprite (use a sprites name for a faceplate of that sprite, or use false or '' for no sprite)
argument2 is text color (false for white, true for black)
argument3 is 'cutscene mode' (no textbox, white or black back inverse to text color)
  • 0

#10 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 03 May 2012 - 12:34 AM

alright fixed. argument1 is now the name of your face sprite. Each face sprite should have an open or closed mouth, with the second subimage being an open mouth, & you'll need a different sprite for each expression.

ti = argument0; //Input text
to = '';        //Output text
tn = 0;         //Text at
c = !argument2;  //color modifier
face = argument1; //face sprite. 
//Give each expression its own mouth open & closed for vowels.
//Open mouth should be the second subimage

io_clear(); //clears the pressed status any previously pressed buttons & input devices for this step
if argument3 = false //If you are not in "Cutscene" mode
{
    draw_background(back_TextBox,0,480-128) //Draws the text box.
    //You can make this your own background
}
else //if you are in 'Cutscene' mode
{
    draw_set_color(make_color_rgb(255*!c,255*!c,255*!c))    //makes the color black or white
    draw_rectangle(0,480-128,640,480,false) //Draws the "text box"
}

while string_length(to) < string_length(ti)
{
    tn += 1;   //Sets the point where the text is at
    if sprite_exists(face) //if you have a face sprite.
    {
        if string_char_at(ti,tn)= 'A' //if there is a vowel at the current piece of text
        ||string_char_at(ti,tn) = 'E'
        ||string_char_at(ti,tn) = 'I'
        ||string_char_at(ti,tn) = 'O'
        ||string_char_at(ti,tn) = 'U'
        ||string_char_at(ti,tn) = 'Y'
        ||string_char_at(ti,tn) = 'a'
        ||string_char_at(ti,tn) = 'e'
        ||string_char_at(ti,tn) = 'i'
        ||string_char_at(ti,tn) = 'o'
        ||string_char_at(ti,tn) = 'y'
        {
            f=1; //mouth will be open
        }
        else f=0; //mouth is closed
        draw_sprite(face,f,8,480-123)
    }
    draw_set_font(fnt_Text)     //Sets the font to your Text font
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(50+8,480-123,to,15,-1);    //Draws the text
    screen_refresh();           //Refreshes the screen (so the text will appear)
    sleep(50);                  //Waits 25 milliseconds before iterating
}
draw_set_color(c_aqua) //sets the color to light blue
draw_triangle(640-2,480-20,640-20,480-20,640-12,480-2,false) //draws a triangle
screen_refresh();   //Refreshes the screen
while !keyboard_check(vk_enter) //Until the Enter key is pressed
{
    sleep(1);   //Waits 1 millisecond
}
screen_redraw();    //redraws the screen, stopping certain graphical glitches

basically:
scr_DrawText('Your Text belongs right here', spr_FaceSprite, false, false)

argument0 is your string,
argument1 is your face sprite (use a sprites name for a faceplate of that sprite, or use false or '' for no sprite)
argument2 is text color (false for white, true for black)
argument3 is 'cutscene mode' (no textbox, white or black back inverse to text color)


Woah, this looks awesome, but I am having a few issues - for some reason when I try and do spr_DamienNeutral or scr_DrawMessage it's saying it's not a real function? Ahahah, sorry, I'm truly a stranger to game maker code

EDIT:

Alright - I got the textbox to appear with the arrow and my little textbox background - but for some reason - no sprite or text? :/

Edited by Minishcactus, 03 May 2012 - 12:45 AM.

  • 0

#11 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 03 May 2012 - 12:56 AM

Need the code you are using to initiate the script to debug so copy & paste that stuff!.

Edited by Lemon Pie, 03 May 2012 - 12:57 AM.

  • 0

#12 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 03 May 2012 - 12:58 AM

Need the code you are using to initiate the script to debug so copy & paste that stuff!.



script_execute('Talk', sprite_index = DamienNeutral, false, false)

  • 0

#13 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 03 May 2012 - 01:08 AM


Need the code you are using to initiate the script to debug so copy & paste that stuff!.



script_execute('Talk', sprite_index = DamienNeutral, false, false)


firstly call the script by its name + () like this (assuming that the name of the script is script_Script)
script_Script();
then you put your arguments in the ()
Also you don't need to do sprite_index = because it is already handled inside the script. All you need is the name of the sprite that will be used as your sprite.
so ending up your code should look like this instead:
scr_DrawText("Text", DamienNeutral, false, false) //change scr_DrawText to the actual name of the script.

Edited by Lemon Pie, 03 May 2012 - 01:09 AM.

  • 0

#14 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 03 May 2012 - 01:11 AM



Need the code you are using to initiate the script to debug so copy & paste that stuff!.



script_execute('Talk', sprite_index = DamienNeutral, false, false)


firstly call the script by its name + () like this (assuming that the name of the script is script_Script)
script_Script();
then you put your arguments in the ()
Also you don't need to do sprite_index = because it is already handled inside the script. All you need is the name of the sprite that will be used as your sprite.
so ending up your code should look like this instead:
scr_DrawText("Text", DamienNeutral, false, false) //change scr_DrawText to the actual name of the script.



When I try to use scr it says "Unknown Function or Script"



___________________________________________
FATAL ERROR in
action number 1
of Collision Event with object Damien
for object Cutscene1:

COMPILATION ERROR in code action
Error in code at line 1:
scr_DrawMessage('Talk', DamienNeutral, true, true)
^
at position 1: Unknown function or script: scr_DrawMessage

Edited by Minishcactus, 03 May 2012 - 01:13 AM.

  • 0

#15 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 03 May 2012 - 01:16 AM

scr_ isnt a function, it is just an identifier that I use in the names of scripts, like obj_ for objects, & spr_ for sprites. It's better programing & it helps me keep everything better organized, as to not end up crossing over the names of 2 resources (like a sprite & object both named Player).
Edit: if your script is named scr_DrawMessage then that should work. If not, change scr_DrawMessage to the actual name of your script.

Edited by Lemon Pie, 03 May 2012 - 01:17 AM.

  • 0

#16 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 03 May 2012 - 01:32 AM

scr_ isnt a function, it is just an identifier that I use in the names of scripts, like obj_ for objects, & spr_ for sprites. It's better programing & it helps me keep everything better organized, as to not end up crossing over the names of 2 resources (like a sprite & object both named Player).
Edit: if your script is named scr_DrawMessage then that should work. If not, change scr_DrawMessage to the actual name of your script.



Ah okay - now I'm getting the face and the message - though the lips aren't moving? I'm trying to understand all this vowel stuff you did...is it so his mouth opens when you use a vowel or something? Anyway....how do I get the font to be in the center in the bottom of the screen?
  • 0

#17 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 03 May 2012 - 01:49 AM

Ah okay - now I'm getting the face and the message - though the lips aren't moving? I'm trying to understand all this vowel stuff you did...is it so his mouth opens when you use a vowel or something? Anyway....how do I get the font to be in the center in the bottom of the screen?

Yes, as long as the first subimage (image_index = 0) in the sprite is the closed mouth & the second subimage (image_index = 1) is the mouth open it will open every vowel & close w/ every consonant or other characters, animating the sprite.
To get centered text change this bit of code:
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(50+8,480-123,to,15,-1);    //Draws the text

to

    draw_set_halign(fa_center) //aligns the font to center.
    draw_set_valign(fa_top)     //Aligns the font to the top.
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(320,480-123,to,15,-1);    //Draws the text

  • 0

#18 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 03 May 2012 - 01:54 AM


Ah okay - now I'm getting the face and the message - though the lips aren't moving? I'm trying to understand all this vowel stuff you did...is it so his mouth opens when you use a vowel or something? Anyway....how do I get the font to be in the center in the bottom of the screen?

Yes, as long as the first subimage (image_index = 0) in the sprite is the closed mouth & the second subimage (image_index = 1) is the mouth open it will open every vowel & close w/ every consonant or other characters, animating the sprite.
To get centered text change this bit of code:
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(50+8,480-123,to,15,-1);    //Draws the text

to

    draw_set_halign(fa_center) //aligns the font to center.
    draw_set_valign(fa_top)     //Aligns the font to the top.
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(320,480-123,to,15,-1);    //Draws the text



Uhoh! This made the text spawn multiple times at once, so it's like a bunch of text running into each other....D:
  • 0

#19 Lemon Pie

Lemon Pie

    GMC Member

  • GMC Member
  • 194 posts

Posted 03 May 2012 - 02:11 AM

hmm... Now that I think about it I didn't account for the text drawing underneath of eachother.
The screen doesn't redraw, & the text is drawn over & over again rather than just once. Now you can easily fix that, however, you will most likely get a graphical error, which looks similar to scan lines, & it will cause alot of CPU strain, as it has to redraw EVERYTHING each time a new letter is added. Or you can simply go back to the text being un-aligned (which I would recommend).

however here is the code as it would look aligned to the center, displaying relatively properly.
ti = argument0; //Input text
to = '';        //Output text
tn = 0;         //Text at
c = !argument2;  //color modifier
face = argument1; //face sprite. 
//Give each expression its own mouth open & closed for vowels.
//Open mouth should be the second subimage

io_clear(); //clears the pressed status any previously pressed buttons & input devices for this step

while string_length(to) < string_length(ti)
{
    if argument3 = false //If you are not in "Cutscene" mode
    {
        draw_background(back_TextBox,0,480-128) //Draws the text box.
        //You can make this your own background
    }
    else //if you are in 'Cutscene' mode
    {
        draw_set_color(make_color_rgb(255*!c, 255*!c, 255*!c))    //makes the color black or white
        draw_rectangle(0,480-128,640,480,false) //Draws the "text box"
    }

    tn += 1;   //Sets the point where the text is at
    if sprite_exists(face) //if you have a face sprite.
    {
        if string_char_at(ti,tn)= 'A' //if there is a vowel at the current piece of text
        ||string_char_at(ti,tn) = 'E'
        ||string_char_at(ti,tn) = 'I'
        ||string_char_at(ti,tn) = 'O'
        ||string_char_at(ti,tn) = 'U'
        ||string_char_at(ti,tn) = 'Y'
        ||string_char_at(ti,tn) = 'a'
        ||string_char_at(ti,tn) = 'e'
        ||string_char_at(ti,tn) = 'i'
        ||string_char_at(ti,tn) = 'o'
        ||string_char_at(ti,tn) = 'y'
        {
            f=1; //mouth will be open
        }
        else f=0; //mouth is closed
        draw_sprite(face,f,8,480-123)
    }
    draw_set_font(fnt_Text)     //Sets the font to your Text font
    draw_set_halign(fa_center)
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(320,480-123,to,15,-1);    //Draws the text
    screen_refresh();           //Refreshes the screen (so the text will appear)
    sleep(50);                  //Waits 25 milliseconds before iterating
    screen_redraw();     //redraws the screen, redrawing all active instance's draw events & sprites.
}
draw_set_color(c_aqua) //sets the color to light blue
draw_triangle(640-2, 480-20, 640-20, 480-20, 640-12, 480-2, false) //draws a triangle
screen_refresh();   //Refreshes the screen
while !keyboard_check(vk_enter) //Until the Enter key is pressed
{
    sleep(1);   //Waits 1 millisecond
}
screen_redraw();    //redraws the screen, stopping certain graphical glitches

Edited by Lemon Pie, 03 May 2012 - 02:15 AM.

  • 0

#20 Minishcactus

Minishcactus

    GMC Member

  • New Member
  • 55 posts
  • Version:Mac

Posted 03 May 2012 - 02:28 AM

hmm... Now that I think about it I didn't account for the text drawing underneath of eachother.
The screen doesn't redraw, & the text is drawn over & over again rather than just once. Now you can easily fix that, however, you will most likely get a graphical error, which looks similar to scan lines, & it will cause alot of CPU strain, as it has to redraw EVERYTHING each time a new letter is added. Or you can simply go back to the text being un-aligned (which I would recommend).

however here is the code as it would look aligned to the center, displaying relatively properly.

ti = argument0; //Input text
to = '';        //Output text
tn = 0;         //Text at
c = !argument2;  //color modifier
face = argument1; //face sprite. 
//Give each expression its own mouth open & closed for vowels.
//Open mouth should be the second subimage

io_clear(); //clears the pressed status any previously pressed buttons & input devices for this step

while string_length(to) < string_length(ti)
{
    if argument3 = false //If you are not in "Cutscene" mode
    {
        draw_background(back_TextBox,0,480-128) //Draws the text box.
        //You can make this your own background
    }
    else //if you are in 'Cutscene' mode
    {
        draw_set_color(make_color_rgb(255*!c, 255*!c, 255*!c))    //makes the color black or white
        draw_rectangle(0,480-128,640,480,false) //Draws the "text box"
    }

    tn += 1;   //Sets the point where the text is at
    if sprite_exists(face) //if you have a face sprite.
    {
        if string_char_at(ti,tn)= 'A' //if there is a vowel at the current piece of text
        ||string_char_at(ti,tn) = 'E'
        ||string_char_at(ti,tn) = 'I'
        ||string_char_at(ti,tn) = 'O'
        ||string_char_at(ti,tn) = 'U'
        ||string_char_at(ti,tn) = 'Y'
        ||string_char_at(ti,tn) = 'a'
        ||string_char_at(ti,tn) = 'e'
        ||string_char_at(ti,tn) = 'i'
        ||string_char_at(ti,tn) = 'o'
        ||string_char_at(ti,tn) = 'y'
        {
            f=1; //mouth will be open
        }
        else f=0; //mouth is closed
        draw_sprite(face,f,8,480-123)
    }
    draw_set_font(fnt_Text)     //Sets the font to your Text font
    draw_set_halign(fa_center)
    draw_set_valign(fa_top)     //Aligns the font
    draw_set_color(make_color_rgb(255*c,255*c,255*c)); //makes the text color
    to = string_copy(ti,0,tn);  //Makes the output string
    draw_text_ext(320,480-123,to,15,-1);    //Draws the text
    screen_refresh();           //Refreshes the screen (so the text will appear)
    sleep(50);                  //Waits 25 milliseconds before iterating
    screen_redraw();     //redraws the screen, redrawing all active instance's draw events & sprites.
}
draw_set_color(c_aqua) //sets the color to light blue
draw_triangle(640-2, 480-20, 640-20, 480-20, 640-12, 480-2, false) //draws a triangle
screen_refresh();   //Refreshes the screen
while !keyboard_check(vk_enter) //Until the Enter key is pressed
{
    sleep(1);   //Waits 1 millisecond
}
screen_redraw();    //redraws the screen, stopping certain graphical glitches


Okay - I reverted --- I wanted to ask, how to I make multiple boxes - so like I press enter, but the person is still talking?

Nevermind - I figured it out! :D

Edited by Minishcactus, 03 May 2012 - 02:30 AM.

  • 0

#21 C_Pike

C_Pike

    GMC Member

  • GMC Member
  • 621 posts
  • Version:GM8.1

Posted 03 May 2012 - 03:24 PM

Here is an easy way to do scrolling text:
http://www.freefileh...t/stringexample

Create:
string_toChange =   "Here's Dwarf Fortress Talk 18, recorded just after the 34.06 release, where we talk about the big release and future developments: forum thread,DF Talk page with download. Threetoe appears for the first time to handle the question and answer portion."
string_show = 30;//How many characters to display
string_x = -string_show;// We will start with no text 
scroll_timer = 4; //How quickly the text will scroll
scroll_theText = scroll_timer;
string_removeEnd = ""
string_removeFront = ""


Draw:
if (keyboard_check_pressed (vk_up))&&(scroll_timer > 0)
    {
    scroll_timer -=1
    scroll_theText = scroll_timer;
    
    };
if (keyboard_check_pressed (vk_down))
    {
    scroll_timer +=1
    scroll_theText = scroll_timer;
    };

if (scroll_theText == 0)
    {
    string_x =(string_x+1) mod string_length(string_toChange); //this moves the string left by one character
                                                                //and loops it if need be
    //This remves the end of the string
    string_removeEnd = string_delete (string_toChange,string_show+string_x,string_length(string_toChange));
    //This removes the front of the string
    string_removeFront = string_delete (string_removeEnd,1,string_x);
    //This resets the timer
    if (string_x+string_show = string_length(string_toChange)+string_show -1)
        {
        //reset the text
        string_x = -string_show;
        string_removeEnd = ""
        string_removeFront = ""
        };
    scroll_theText = scroll_timer;
    };
else
    {
    scroll_theText -= 1;//This is the timer countdown
    };    

//this draws the text
draw_text (x,y,"> "+string_removeFront+" <");

//this is the key help
draw_text (x,y+string_height("O")*2,"Up & Down keys to change the delay: ("+string(scroll_timer)+")#"+
"Text position: "+string(string_x+string_show)+"#Total string length: "+string(string_length(string_toChange)) );

Its not as sweet as the one posted above, but it is functional.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users