Discuss Scratch

StarSpacer
Scratcher
4 posts

Speed

Hello Everybody

I need help with speed. I want to make a variable which the user can adjust or change for speed. Could anyone help me out? Any help would be appreciated!

StarSpacer
kiwilover2736
Scratcher
1000+ posts

Speed

This belongs in the help with scripts forum! Anyways, i can help you!

First make a variable called “speed.” Then you can choose to make it a slider by right clicking the variable on the stage and clicking the “slider” option. You can right click it again to change minimum and maximum speed. Then you can add the variable to your movement scripts! Here's an example:

when green flag clicked
forever
if <key [right arrow key] pressed?> then
change x by (Speed)
end
if <key [left arrow key] pressed?> then
change x by ((0) - (Speed))
end
if <key [up arrow key] pressed?> then
change y by (Speed)
end
if <key [down arrow key] pressed?> then
change y by ((0) - (Speed))
end
end
kiwilover2736
Scratcher
1000+ posts

Speed

If you need extra help adding the variable to your movement scripts you can ask me!
cosmosaura
Scratch Team
1000+ posts

Speed

I'll move this over to the Help with Scripts section for you - that's a better fit for this kind of topic
Spentiline
Scratcher
100+ posts

Speed

You can use this:

when I receive [movement v]
forever
change x by ((speed :: grey) * (<key (right arrow v) pressed?> - <key (left arrow v) pressed?>))
change y by ((speed :: grey) * (<key (up arrow v) pressed?> - <key (down arrow v) pressed?>))
end
StarSpacer
Scratcher
4 posts

Speed

Thank you everyone.
It worked.
Thank you
StarSpacer!

Powered by DjangoBB