Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to get an Animation to stop when button is not held down?
- United_Snakes53
-
6 posts
How to get an Animation to stop when button is not held down?
Have a sprite that has a walking animation and I want it to use the animation while a button is held down. However I want it to immediately stop the walking animation as soon as the button is not pressed. The sprite however keeps doing the animation until it finishes the cycle, which I do not want. This is the script I´m using.
Last edited by United_Snakes53 (April 28, 2017 19:21:49)
- United_Snakes53
-
6 posts
How to get an Animation to stop when button is not held down?
Sorry messed up.
- rpglurker
-
100+ posts
How to get an Animation to stop when button is not held down?
This block works for most programs, but the costume switch below the animation loop will not run until the wait period expires. Your code could not exit the loop early because the exit condition did not get checked until it finished the sequence. You can either change it to use next costume (see below -
it is better code anyway) or you could have another script running that “stops other scripts” with a stop block (this is kind of a cludgy fix)…
it is better code anyway) or you could have another script running that “stops other scripts” with a stop block (this is kind of a cludgy fix)…
- United_Snakes53
-
6 posts
How to get an Animation to stop when button is not held down?
It worked. Kinda. This block works for most programs, but the costume switch below the animation loop will not run until the wait period expires. Your code could not exit the loop early because the exit condition did not get checked until it finished the sequence. You can either change it to use next costume (see below -
it is better code anyway) or you could have another script running that “stops other scripts” with a stop block (this is kind of a cludgy fix)…
I have other costumes in the sprite, and I want the walk animation to loop when the button is held down. With your script it goes to the other costumes when held down. Any suggestions please?
- WolfCat67
-
1000+ posts
How to get an Animation to stop when button is not held down?
You can use this:
Though not the best, it'll continually wait until you're using that button, at which point it will start the animation. Upon letting go, it'll immediately stop, as it only will continue if you press the button again.
- CommunistToaster
-
3 posts
How to get an Animation to stop when button is not held down?
I tried this and now pressing a does not allow the sprite to move on the x axis by -1. It's playing the animation perfectly though This block works for most programs, but the costume switch below the animation loop will not run until the wait period expires. Your code could not exit the loop early because the exit condition did not get checked until it finished the sequence. You can either change it to use next costume (see below -
it is better code anyway) or you could have another script running that “stops other scripts” with a stop block (this is kind of a cludgy fix)…
- -ShadowOfTheFuture-
-
1000+ posts
How to get an Animation to stop when button is not held down?
I tried this and now pressing a does not allow the sprite to move on the x axis by -1. It's playing the animation perfectly though
Please create a new topic for your own question. Thanks!
I'm leaving this open for now, since it doesn't seem to be completely resolved. In case the original poster is still looking for a solution, this might work, although it's a bit complicated and only works if those are the only scripts in the sprite:
- SkyGuy354
-
19 posts
How to get an Animation to stop when button is not held down?
You can use this:Though not the best, it'll continually wait until you're using that button, at which point it will start the animation. Upon letting go, it'll immediately stop, as it only will continue if you press the button again.
I think that's the simplest one though
sorry i suck at scratchblocks
- Freddyfangames1010
-
8 posts
How to get an Animation to stop when button is not held down?
If your making a game where you have a full walking animation with many costumes and when you stop holding the walking key it goes back to idle costume, go with my way. Let's start with the “When Green Flag Clicked” Events script block. Put a “Forever” Control script block under. Then put an “If ____ Then” Block under it. Inside that blank, put the “Key _____ pressed?” Sensing script block. Inside that blank, click the down arrow and select which key you would like to use. Next add a “Repeat Until ______” Control script block. Inside the blank, put the “Not ______” Operator script block. Inside that blank, put the “Key ______ pressed?” Sensing script block and select the same key as last time. Inside the “Repeat Until Not Key _______ pressed?” script, put the “Switch Costume to _____” Look script block. And in that blank, click the down arrow and select the costume you want for your first walking animation part. Under the “Switch costume to ______” script block, put the “Wait ___ secs” Control script block. in the blank put how long it will stay in that costume. Then keep going with the “Switch costume to _____” and “Wait _____ secs” Script blocks until you want your animation to restart. Now get ready for a new script. Put the “When Green Flag Clicked” Event script block. And under, put the “Switch costume to ____” look script block. In the blank put your idle costume. Get ready for another script. Put the “When Green Flag Clicked” Events script block. Under it, put the “Forever” Control loop script block. inside it put the “Wait until _____” Control script block. Inside the blank, put the “Not ______” Operator script block. Inside the blank, put the “Key _____ pressed?” Sensing script block. Inside the blank, put the same key as last time. Under it, put the “Switch costume to ___” inside the blank, put your idle costume. Hope it works out!
- deck26
-
1000+ posts
How to get an Animation to stop when button is not held down?
There's a sticky topic at the top of the forum if you want to practice with Scratchblocks! If your making a game where you have a full walking animation with many costumes and when you stop holding the walking key it goes back to idle costume, go with my way. Let's start with the “When Green Flag Clicked” Events script block. Put a “Forever” Control script block under. Then put an “If ____ Then” Block under it. Inside that blank, put the “Key _____ pressed?” Sensing script block. Inside that blank, click the down arrow and select which key you would like to use. Next add a “Repeat Until ______” Control script block. Inside the blank, put the “Not ______” Operator script block. Inside that blank, put the “Key ______ pressed?” Sensing script block and select the same key as last time. Inside the “Repeat Until Not Key _______ pressed?” script, put the “Switch Costume to _____” Look script block. And in that blank, click the down arrow and select the costume you want for your first walking animation part. Under the “Switch costume to ______” script block, put the “Wait ___ secs” Control script block. in the blank put how long it will stay in that costume. Then keep going with the “Switch costume to _____” and “Wait _____ secs” Script blocks until you want your animation to restart. Now get ready for a new script. Put the “When Green Flag Clicked” Event script block. And under, put the “Switch costume to ____” look script block. In the blank put your idle costume. Get ready for another script. Put the “When Green Flag Clicked” Events script block. Under it, put the “Forever” Control loop script block. inside it put the “Wait until _____” Control script block. Inside the blank, put the “Not ______” Operator script block. Inside the blank, put the “Key _____ pressed?” Sensing script block. Inside the blank, put the same key as last time. Under it, put the “Switch costume to ___” inside the blank, put your idle costume. Hope it works out!
- Carol_Studio
-
1 post
How to get an Animation to stop when button is not held down?
THANK YOU SO MUCH!!! This worked so well, and it's not glitchy. Your so easy to follow, and I'm super happy with my project! Thank you!!
- QuirkyKittten
-
100+ posts
How to get an Animation to stop when button is not held down?
I can help. Instead of having nothing in the “Else” section, I would preferably put the “stop this script” like this: Have a sprite that has a walking animation and I want it to use the animation while a button is held down. However I want it to immediately stop the walking animation as soon as the button is not pressed. The sprite however keeps doing the animation until it finishes the cycle, which I do not want. This is the script I´m using.
Last edited by QuirkyKittten (Jan. 20, 2020 17:33:42)
- deck26
-
1000+ posts
How to get an Animation to stop when button is not held down?
Please check the date before posting. This topic is old.I can help. Instead of having nothing in the “Else” section, I would preferably put the “stop this script” like this: Have a sprite that has a walking animation and I want it to use the animation while a button is held down. However I want it to immediately stop the walking animation as soon as the button is not pressed. The sprite however keeps doing the animation until it finishes the cycle, which I do not want. This is the script I´m using.
- scratchPro86
-
15 posts
How to get an Animation to stop when button is not held down?
But how do i make the sprite stop if i press space bar again


?




- deck26
-
1000+ posts
How to get an Animation to stop when button is not held down?
Please create you own new topic rather than necroposting. You can always cut and paste something from here or refer to this topic if necessary but more likely you can just share your project and say what you're trying to do. But how do i make the sprite stop if i press space bar again?
- -Esther
-
1 post
How to get an Animation to stop when button is not held down?
.
Last edited by -Esther (Aug. 24, 2020 02:39:07)
- HootDug
-
66 posts
How to get an Animation to stop when button is not held down?
Hey guys how do i post??!??! so i can create my pol lol
- HootDug
-
66 posts
How to get an Animation to stop when button is not held down?
Can anyone help me? i need the costume 4 to stop until i stop holding the letter Here is the pic http://prntscr.com/v5qpkd
- qucchia
-
100+ posts
How to get an Animation to stop when button is not held down?
Please create your own topic instead of posting on an old one
- HootDug
-
66 posts
How to get an Animation to stop when button is not held down?
How do i make a topic??!?!? 

- Discussion Forums
- » Help with Scripts
-
» How to get an Animation to stop when button is not held down?