Game Development Community

Typewriter Text effect

by Kevin Epps · in Torque Game Builder · 03/26/2007 (8:03 pm) · 3 replies

Has anyone succeeded in getting this? Like pretty much have the text print out a character at a time?

#1
03/26/2007 (8:13 pm)
@Kevin -- is this being done by user input ... or do you want the old NES style letter-at-a-time thing?

You could create a t2dTextObject, place it, set the font, size it, etc ... then create a dynamic field called "CompleteText" and then use the following:

function typeWriterTextObject::onTimer(%this)
{
  %this.text = %this.text @ getSubStr(%this.CompleteText, strlen(%this.text), 1);

  // uncomment below for sound
  // playSound(typeWriterAudio);
}

function typeWriterTextObject::onLevelLoaded(%this, %sg)
{
  %this.setTimerOn(%this.textSpeed * 1000);
}

Something similar to that ... you'd create two Dynamic Fields "CompleteText" and "TextSpeed" -- TextSpeed would be the number of seconds to wait between letters ... "0.5" would drawn 2 letters per second, for example --

Create a "typeWriterAudio" sound datablack, and you can have it play that ever annoying sound as it does it too ... with a fixed-width font, I think this would work quite well ...

Another alternative to using t2dTextObject, is using the TGB Bitmap Font resource I released a few weeks ago ... depending on your font requirements ...
#2
03/26/2007 (9:00 pm)
Great! Thanks David! I'll download the resource as well! Thanks a lot!
#3
03/27/2007 (10:25 am)
See my reply on Mar 18th:
BulletLabel thread

That's source code for a typewriter text object with optional multiple lines.