Discuss Scratch

Baselira
Scratcher
15 posts

How to make a sprite go back to standing costume?

The code I have is changing costumes while running, but when it stops running(the player stops holding down the key) it stays in the running costume. I've tried various “If” scripts that don't work, and if I incorporate it at the end of the script it adds an extra weird frame that makes it much less smooth and makes it look glitchy. Is there a script that can make it so when the player stops pressing on the button the costume switches to the standing position?
deck26
Scratcher
1000+ posts

How to make a sprite go back to standing costume?

You must have a script or loop that is active when the sprite is running. If you switch costume when the running stops that should be enough. Sharing the project would help.
Baselira
Scratcher
15 posts

How to make a sprite go back to standing costume?

deck26 wrote:

You must have a script or loop that is active when the sprite is running. If you switch costume when the running stops that should be enough. Sharing the project would help.
Okay, heres the link:

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


Itll stay in the running position when I stop pressing the key. And also, I've tried the switch the costumes for running, then if else switch to standing but it doesnt work when I do that ;-;
deck26
Scratcher
1000+ posts

How to make a sprite go back to standing costume?

At the moment your project has no green flag scripts so it is only responding to key presses and when no key is pressed it is not going to do anything.

What you should do is have a green flag script which contains a forever loop looking for key presses rather than using the keypress hat block.

whenclickedforeverifkeyup arrowpressed?theninsertyourcodeforuparrowhereelseifkeydown arrowpressed?thendownarrowcodehereelseifkeyright arrowpressed?thenrightarrowcodeelseifkeyleft arrowpressed?thenleftarrowcodeelseswitchcostumetocostume1
So where I have red blocks you should actually be putting in the code you currently have for that key press.
Baselira
Scratcher
15 posts

How to make a sprite go back to standing costume?

deck26 wrote:

At the moment your project has no green flag scripts so it is only responding to key presses and when no key is pressed it is not going to do anything.

What you should do is have a green flag script which contains a forever loop looking for key presses rather than using the keypress hat block.

whenclickedforeverifkeyup arrowpressed?theninsertyourcodeforuparrowhereelseifkeydown arrowpressed?thendownarrowcodehereelseifkeyright arrowpressed?thenrightarrowcodeelseifkeyleft arrowpressed?thenleftarrowcodeelseswitchcostumetocostume1
So where I have red blocks you should actually be putting in the code you currently have for that key press.
OH it worked! I had this problem in one of my other games, now its solved! Thanks, this was SO helpful ;c;

Last edited by Baselira (Oct. 9, 2015 21:45:48)

Grofskembo
New Scratcher
1 post

How to make a sprite go back to standing costume?

Well, im having the same problem but i have two costumes for standing positions (eg. after running to left staying in standing position but turned to left side and opposite) is that possible using Scratch commands?
deck26
Scratcher
1000+ posts

How to make a sprite go back to standing costume?

Grofskembo wrote:

Well, im having the same problem but i have two costumes for standing positions (eg. after running to left staying in standing position but turned to left side and opposite) is that possible using Scratch commands?
Best to start your own new topic rather than necroposting. Sharing what you have is also a good idea. Do you really need two standing costumes?

Powered by DjangoBB