Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you get a sprite to stop moving immediately after a key is pressed?
- AE-Wolf
-
8 posts
How do you get a sprite to stop moving immediately after a key is pressed?
Hi! I'm working on a game for school, but I can't figure out how to get the sprite to stop moving right after a key is pressed.
Here is the script and this is the entire program. All I need to do is fix this script and the program will be good to go. This project is due tomorrow, so I'll be willing to take any advice/suggestions. Thanks!
Here is the script and this is the entire program. All I need to do is fix this script and the program will be good to go. This project is due tomorrow, so I'll be willing to take any advice/suggestions. Thanks!
Last edited by AE-Wolf (March 15, 2016 19:09:29)
- prettydarnamazing
-
100+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
when [space v] key pressed
repeat until <not <key [space v] pressed?>>
move (4) steps
end
- AE-Wolf
-
8 posts
How do you get a sprite to stop moving immediately after a key is pressed?
Thank you for the suggestion! I think I might have an idea of what to do, but I'm still stuck. This is the script I have:
when I receive [ yellow]
repeat until <key [ space] pressed?>
glide (1) secs to x: (-82) y: (77)
glide (1) secs to x: (217) y: (77)
end
broadcast [ yellowd]
- deck26
-
1000+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
You can't interrupt a glide so for the two seconds you're gliding any space being pressed is being ignored.
- EliBraz
-
5 posts
How do you get a sprite to stop moving immediately after a key is pressed?
That Makes No Sense You can't interrupt a glide so for the two seconds you're gliding any space being pressed is being ignored.
- drmcw
-
1000+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
Makes sense to me. The 2 glide blocks take 2 seconds to run so the space key detection in the repeat will only run every 2 seconds.That Makes No Sense You can't interrupt a glide so for the two seconds you're gliding any space being pressed is being ignored.
- aarushm22
-
100+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
when green flag clicked
forever
if <key [right arrow v] pressed> then
forever
point in direction (90 v)
move (10) steps
forever
if <key [space v] pressed> then
stop [this script v]
end
end
end
end
- TheNonNameMouse
-
88 posts
How do you get a sprite to stop moving immediately after a key is pressed?
if <> then
glide (1) secs to x: (0) y: (0)
else
stop [this script v]
end
- aarushm22
-
100+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
when green flag clicked
repeat until <I multiply every thing by 5 forever>
forever multiply every thing in the project by (5 v)
end
Last edited by aarushm22 (March 15, 2016 20:32:46)
- drmcw
-
1000+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
To answer the original question assuming they still want to use glides then https://scratch.mit.edu/projects/101828381/
- deck26
-
1000+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
Three nested forever loops are never going to be a good idea!when green flag clicked
forever
if <key [right arrow v] pressed> then
forever
point in direction (90 v)
move (10) steps
forever
if <key [space v] pressed> then
stop [this script v]
end
end
end
end
- prettydarnamazing
-
100+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
makes sense to me too.Makes sense to me. The 2 glide blocks take 2 seconds to run so the space key detection in the repeat will only run every 2 seconds.That Makes No Sense You can't interrupt a glide so for the two seconds you're gliding any space being pressed is being ignored.
The reason it doesn't make sense is cause ur new to scratch. Deck26 is a pro.
- AE-Wolf
-
8 posts
How do you get a sprite to stop moving immediately after a key is pressed?
Thanks guys, this really helped!
- LeftHandManGames
-
25 posts
How do you get a sprite to stop moving immediately after a key is pressed?
this doesnt help it just moves over one step and stops until you press the script again how do you add an animation to it
- deck26
-
1000+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
Please create your own topic rather than necroposting. Share the project and describe your problem. this doesnt help it just moves over one step and stops until you press the script again how do you add an animation to it
- Dan3DTV
-
20 posts
How do you get a sprite to stop moving immediately after a key is pressed?
when green flag clicked
forever
if <key [space] pressed?> then
change x by (4)
end
end
- scratchPro86
-
15 posts
How do you get a sprite to stop moving immediately after a key is pressed?
I'm trying to stop a player from hitting an animal when the same button is pressed to start the player hitting the animal
Any help please??
I'm new to scratch
Any help please??
I'm new to scratch
- LeonLeontije26
-
1 post
How do you get a sprite to stop moving immediately after a key is pressed?
when green flag clicked
forever
if <> then
stop [ this script]
end
end
Last edited by LeonLeontije26 (April 11, 2021 09:15:19)
- Tronche2Cake
-
100+ posts
How do you get a sprite to stop moving immediately after a key is pressed?
when green flag clicked
forever
if <> then
stop [ this script]
end
end
You're new to the forums I see. This post was made in 2016 and is considered dead. You posted a comment on it, which is called necroposting. It's annoying because it makes the post go back to the front of the forums even though people don't need it anymore.
Don't worry, we've all been there at some point, but check the date next time or forum lurkers will spam your account telling you not to necropost.
- sloth_yyy
-
8 posts
How do you get a sprite to stop moving immediately after a key is pressed?
lol
- Discussion Forums
- » Help with Scripts
-
» How do you get a sprite to stop moving immediately after a key is pressed?