Discuss Scratch

bunnycraft99
Scratcher
2 posts

Making a letter appear once at a time

I was going to make a big game for scratch and now i am starting on it. I wanted to try something new were the letters come one at a time in speech. like when a sprite is talking. I tried searching but nothing seems to be optional or make much sense. Please help and give me the exact script. Thank you.
Garfield14
Scratcher
3 posts

Making a letter appear once at a time

It's actually not that difficult. Here. So have each letter as a sprite. Drag each letter sprite to where you want it to show up.
go to x: () y: (0)
alexphan
Scratcher
1000+ posts

Making a letter appear once at a time

Garfield14 wrote:

It's actually not that difficult. Here. So have each letter as a sprite. Drag each letter sprite to where you want it to show up.
go to x: () y: (0)
I think the OP means having one letter at a time show when a sprite is talking through the say blocks.

Try this:

define say [text] //This contains the function
set [txt v] to [] //Sets "txt" to nothing (blank)
set [i v] to [1] //Sets "i" to 1; we will use this to go through the entire text.
repeat (length of (text)) //You want to go through all of the text.
set [txt v] to (join (txt) (letter (i) of (text)))
say (txt) //Say whatever's in the variable txt. You can change to think if you want to.
change [i v] by (1) //Move on to the next letter
wait (0.05) secs //This is optional; you can put a wait block if you want delays.
end
ivancr72
Scratcher
100+ posts

Making a letter appear once at a time

Ninja'd!
Make two variables (in this example called I and R), and then use this:
define smooth say (text to say)
set [I v] to [1]
set [R v] to []
repeat (length of (text to say::custom-arg))
set [R v] to (join (R) (letter (I) of (text to say::custom-arg)))
say (R)
wait (0.05) secs
change [i v] by (1)
end
Scripts not tested

Last edited by ivancr72 (June 30, 2016 21:23:50)

bunnycraft99
Scratcher
2 posts

Making a letter appear once at a time

Its me again. Do I make the sprite talk after that? I tried and nothing was working right. Also if you can, can you help me see if space is broadcast and when I click it, it will make it turn into the next sentence. Give specific answers with that.Thank you.
footsocktoe
Scratcher
1000+ posts

Making a letter appear once at a time

bunnycraft99 wrote:

Its me again. Do I make the sprite talk after that? I tried and nothing was working right. Also if you can, can you help me see if space is broadcast and when I click it, it will make it turn into the next sentence. Give specific answers with that.Thank you.

The define block above sits off to the side. It will have another block separate that says "smooth say text to say“ in purple. That block goes in your script at the point where you want character to say something. You replace the empty ”text to say" part with what you want the character to say.

Each time the character says something, you use that block again. But there will only be one define block.
footsocktoe
Scratcher
1000+ posts

Making a letter appear once at a time

Here… this will show you how it works…

https://scratch.mit.edu/projects/115324471/

Powered by DjangoBB