Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make my text shake?
- puff77
-
Scratcher
26 posts
How do I make my text shake?
I'm trying to make a game with the same talking methods as the ‘type writer + textbox’ type of text engine. (Example: Undertale, pebble, not that dead, etc) I want to add shaky text for when a character might be yelling, but I'm just not sure how to. If someone could help, I'd really appreciate it :3 <3
My code that I have so far works pretty well (i'm not sure how), but I just can't get the shaky effect to work. Even if I copy the code from plebble the other world (yep, trying to learn code by copying/observing without taking any classes-) (awesomeal82 is really cool don't judge xd), it still doesn't work for me, and I can't figure out what's going wrong for me.
The code below is along the lines of the same thing, but it's pretty much simplified so that I don't have to write the full thing
I know that it will just continuously add onto its last position, which is why I get this weird text floating effect, but if I do some sort of variable thing where I set the current x and y position to that, the next clone will just update the variable and make the letters go to the same position instead! I really want to avoid creating hundreds of variables, but I'm not sure what to do… please help me.
If you want to look at my text engine so far, it's here: https://scratch.mit.edu/projects/1119878878/
My code that I have so far works pretty well (i'm not sure how), but I just can't get the shaky effect to work. Even if I copy the code from plebble the other world (yep, trying to learn code by copying/observing without taking any classes-) (awesomeal82 is really cool don't judge xd), it still doesn't work for me, and I can't figure out what's going wrong for me.
The code below is along the lines of the same thing, but it's pretty much simplified so that I don't have to write the full thing
define say(stuff) shake?(yes or no)
delete all of [Text v]
say [and then after this is the setup for where things should go and what layer]
set [repeator v] to [0]
set [wipe v] to [0]
if <(yes or no) = [yes]> then
set [shake v] to [1]
else
set [shake v] to [0]
end
repeat (length of [Text v] :: list)
change [repeator v] by (1)
switch costume to [(letter (repeator) of (list :: Text) v]
say [then I put a function in case of a line change]
create clone of [myself v]
change x by (10)
end
wait (0) secs
wait until <key [space v] pressed?>
wait until <<not <key [space v] pressed?>>>
set [wipe v] to [1]
when I start as a clone
repeat until <(wipe) = [1]>
if <[(shake)] = [1]> then
go to x: ((x position) + (pick random (-1) to (1))) y: ((y position) + (pick random (-1) to (1)))
end
end
I know that it will just continuously add onto its last position, which is why I get this weird text floating effect, but if I do some sort of variable thing where I set the current x and y position to that, the next clone will just update the variable and make the letters go to the same position instead! I really want to avoid creating hundreds of variables, but I'm not sure what to do… please help me.
If you want to look at my text engine so far, it's here: https://scratch.mit.edu/projects/1119878878/
- RokCoder
-
Scratcher
1000+ posts
How do I make my text shake?
You need to store the original x and y coordinates
when I start as a clone
set [_x v] to (x position) // For this sprite only variable
set [_y v] to (y position) // For this sprite only variable
repeat until <(wipe) = (1)>
if <(shake) = (1)> then
go to x: ((_x) + (pick random (-1) to (1))) y: ((_y) + (pick random (-1) to (1)))
- puff77
-
Scratcher
26 posts
How do I make my text shake?
OHHHH IT'S A for this sprite only variable… it all makes sense now thank you!!
(I will unshare the project now)
(I will unshare the project now)- Discussion Forums
- » Help with Scripts
-
» How do I make my text shake?