Typewriter text effect?

Get help using Construct 2

Post » Fri Oct 14, 2011 7:29 pm

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!
B
3
G
1
Posts: 8
Reputation: 591

Post » Fri Oct 14, 2011 8:45 pm

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.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Oct 14, 2011 8:45 pm

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:

http://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! ) 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.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Oct 14, 2011 9:06 pm

Here's a one-event version!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Fri Oct 14, 2011 9:31 pm

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 :)



B
3
G
1
Posts: 8
Reputation: 591

Post » Fri Nov 11, 2011 1:44 pm

Is there a way to outline and color the inside of a text object so you can create a speech bubble?
Guyon2011-11-12 01:45:13
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Fri Nov 11, 2011 1:49 pm

nooo! families delayed ... ahh wel

wow great example!vtrix2011-11-11 13:50:43
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Dec 21, 2011 6:18 pm

[QUOTE=Ashley] Here's a one-event version![/QUOTE]

Just what i was looking for! THNX
B
17
S
3
G
5
Posts: 71
Reputation: 4,401

Post » Sun Jan 01, 2012 6:21 pm

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
B
3
G
1
Posts: 1
Reputation: 527

Post » Sun Jan 01, 2012 6:54 pm

@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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests