Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1315429 Posts in 58983 Topics- by 50094 Members - Latest Member: makerspender

September 26, 2017, 08:12:34 am

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsBare-bones Typewriter Text
Pages: [1]
Print
Author Topic: Bare-bones Typewriter Text  (Read 10121 times)
Ant
Guest
« on: October 04, 2010, 01:54:32 am »

After wanting some typewriter text for my game (so the text gradually appears one letter at a time) I did some searching for a tutorial and quickly found every example I came across was encased in a bunch of RPG 'extras' such as dialogue boxes and multiple answers. All I wanted was the bare-bones and after a bit of trial and error it turns out it's pretty damn easy.

So first of all you'll need to create an object that will be responsible for writing the text on screen. Inside the object's Create event add the following:

Code:
vText = "Show Me"; //This is the text we want to display
iText = 0; //This variable controls how many letters are currently shown (e.g. if iText = 8 then the first 8 letters of vText will be shown
alarm[0] = 1; //Here we set the whole script in motion

In the object's alarm[0] event add the following:

Code:
//We use an if statement here so the alarm stops once the full text is displayed
if iText <= string_length(vText)
{
  iText += 1; //Here we simply add 1 to iText to show one extra letter
  alarm[0] = 10; //This controls how fast the text is written. Increase this if you want it slower
}

And finally we need to show the text, so in the object's Draw event add the following:

Code:
draw_text(x,y,string_copy(vText,1,iText));

And there you have it, job done!

Currently that will only display a single text string, however it's very easy to modify it so you can have a single object control many different strings. The obvious examples for this would be a dialogue or an inventory screen where the text is changed based on the highlighted item. In these cases all you would need to do is change the vText to the new text, reset the iText back to 0 and restart the alarm[0].
« Last Edit: November 11, 2010, 04:38:07 am by Ant » Logged
antymattar
Level 5
*****


Has earned the contemporary *Banned* medal


View Profile Email
« Reply #1 on: October 28, 2010, 02:49:15 am »

THAT... WAS.... EPIC!!!   Hand Point Left Cool  Hand Metal Right

So many projects would have not been abandoned if I had had this.  Cave Story
Logged

man of doom
Level 2
**


It's not Tom and Jerry!


View Profile WWW
« Reply #2 on: October 29, 2010, 03:56:45 am »

This is awesome, I've been wondering how to do this for ages. Cheers man!
Logged

http://manofdoom.co.uk
Where all my stuff is at!
http://soundcloud.com/man-of-doom
Various musical stuff of mine
phubans
Indier Than Thou
Level 10
*


TIG Mascot


View Profile WWW Email
« Reply #3 on: November 10, 2010, 08:29:42 pm »

Thanks! This was very light & useful.
Logged

Glyph
Level 10
*****


Relax! It's all a dream! It HAS to be!


View Profile
« Reply #4 on: November 12, 2010, 04:29:01 am »

Aw, cool! I'd been wondering about how to do this just recently. string_copy works like a charm!
Logged


Raku
Level 10
*****

Dream's Bell


View Profile WWW
« Reply #5 on: November 28, 2010, 02:16:15 am »

Ah~ thank you so much! This will definitely come in handy!

p.s.

I have another question I forgot to ask, and I don't want to double post.
How do you make it so that it types the words out, erases them, then types another sentence?
(I'm working on a game right now and I'm going to use this for the prologue.)
« Last Edit: November 28, 2010, 02:40:42 am by Rakugaki-Otoko » Logged

GZ
Level 1
*



View Profile WWW Email
« Reply #6 on: November 28, 2010, 01:11:24 pm »

Ah~ thank you so much! This will definitely come in handy!

p.s.

I have another question I forgot to ask, and I don't want to double post.
How do you make it so that it types the words out, erases them, then types another sentence?
(I'm working on a game right now and I'm going to use this for the prologue.)
I've made an example integrating this dialog system with a queue system to demonstrate how you can do this:

http://gzstorm.com/gmhelp/Dialog0.gmk

Be sure to check the game information, it has information on the system.
Logged

Raku
Level 10
*****

Dream's Bell


View Profile WWW
« Reply #7 on: November 28, 2010, 01:16:21 pm »

Ah, thank you very much! This teaches me several things. I'll be sure to come back and ask more questions if they arise.
Logged

jkd003
Guest
« Reply #8 on: November 13, 2011, 12:45:47 pm »

I found your tutorial very helpful. Thank you GZ!
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile WWW Email
« Reply #9 on: November 25, 2011, 07:53:22 am »

Thanks, homes. The love of Jesas will invade your insides to keep you warm through the night. I guarantee it. Corny Laugh
Logged

Yeah.
jericito
Level 0
**


i <3 pixels


View Profile WWW Email
« Reply #10 on: February 16, 2012, 09:04:20 am »

AWW YEEA! GOOD STUFF!!  Hand Thumbs Up Left Hand Thumbs Up Right
Logged

BomberTREE
Level 9
****


sometimes I delete smileys from my old posts


View Profile WWW
« Reply #11 on: April 22, 2012, 02:16:16 pm »

Thank you, very much.  Shocked
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic