Typewriter text effect?

0 favourites
From the Asset Store
Keyboard, Mouse & Typewriter SFX / 27 Unique Sound Clips
  • Hi all,

    Trying to figure out if this is possible. Do you know what I mean? It's a fairly simple effect. Having text appear one letter at a time with like a half or 1 second delay between letters. Each time a letter appears you might also have a typing sound effect go with it.

    I found something on this for Construct Classic but being relatively new to Construct in general it made my head spin, didn't see how I could "port" it over to C2 either.

    Anyone done this successfully yet?

    Thanks in advance either way!

  • It should be, but I'm not sure if Construct 2 has the Mid string expression.

    If it does, try a local variable that increases by 1 every 1/2 second (500ms) and then have your text display as Mid([your string], [local variable], 1).

    If it doesn't, then you could do something like storing each letter into a seperate array memory space, and every 1/2 second add the next array item to the text.

  • There's no prebuilt way to do it, but setting it up yourself is pretty simple. Here's a way to do it in three short events:

    db.tt/YxbrKASu

    It's mostly straightforward, except for the mid() function if you're unfamiliar with it. Its function is to take a smaller part out of a whole string. It takes three parameters, a text variable (or the string itself, if you want) that you want to display, the letter you want to start on, and how many letters from there you want to go.

    So the way I wrote it is, the variable TextCount is incremented once a tick. Every time it's divisible by 5 (which happens twelve times a second), use the mid function. It looks like mid(Cake,0,(TextCount/5)), so let's break that down.

    Cake is the text variable I made, which says "This cake is delicious!" (yum! <img src="smileys/smiley4.gif" border="0" align="middle" />) 0 is the letter you want to start on, which is the first one, "T". TextCount/5 is how long you want it to go on for -- since TextCount is divisble by 5 every time the function is used, that'll always be a whole number. When TextCount is 5, TextCount/5 is 1, so mid is taking the substring of Cake from letters 0 to 1, which only includes "T". Once TextCount is 10, TextCount/5 is 2, so mid takes 0 to 2, which is "Th". It keeps going on until the entire string is displayed piece by piece.

    Hopefully this is what you're looking for and hopefully my explanation was good enough. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Here's a one-event version!

  • Oh wow, thanks you guys!

    So many different ways to do it and I didn't think of any of them. lol

    Thanks so much for helping me out with examples and everything, appreciate your time :)

  • Is there a way to outline and color the inside of a text object so you can create a speech bubble?

  • nooo! families delayed <img src="smileys/smiley19.gif" border="0" align="middle" /> ... ahh wel<img src="smileys/smiley4.gif" border="0" align="middle" />

    wow great example!

  • Here's a one-event version!

    Just what i was looking for! THNX <img src="smileys/smiley1.gif" border="0" align="middle">

  • Awesome been wondering how to do this.

    I messed around with the event Ashley posted and if you make a global var with a value of 0.05 to replace the 0.05 within the 'Every X Seconds' condition you can then use key down and key release events to change the speed that the text 'types'

    I'd imagine a global variable would be the best way to go?

    I do have a question though, actually 2

    1. Is there a way to check when you're at the end of the text block? For example 3 lines of text come and then you can press a button to bring the next 3 lines of text? If that makes sense. An example of this being most rpg games on handhelds.

    2. Can Construct read from text files (or equivalent)? For example can it open a text file and pull X amount of lines from it to add to an array which can then be output via the text object?

    I figure I'd just hijack this thread instead of posting a new topic :D

  • Equix

    1) this should be straightforward using different text objects - maybe post what you've tried if you're stuck?

    2) C2 games run in a browser so obviously can't just load any old file on your computer hard disk, but you could think about using the AJAX object instead.

  • (Another hijack) Is there any way to have a blinking cursor at the end of this effect?

  • Big bump!

    Sorry, just had a question about Ashley's one event version.

    How exactly can I tell it to stop and do something after all of the text has been displayed? RIght now, since it types a letter every 0.05 seconds, anything I try to do after it will also repeat every 0.05 seconds.

  • Basically, what I would like to happen is that once all the lines of text have been displayed, for something else to happen. Anything, a click 2 continue indicator, a new text box...the game exploding. Whatever, just need to be able to tell how the text has finished typing out.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just use "Compare Two Values".

    +len(DestText.text) is greater or equal to len(SourceText.text)

    -> Display an arrow for the next message or something

  • Argh!

    I really need to learn more about expressions. Thanks so much for the help, works beautifully.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)