Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How Can I Make a Sprite Change Costumes When It Moves?
- LittlePony
-
100+ posts
How Can I Make a Sprite Change Costumes When It Moves?
I've been on scratch for a long time, but I never made a platformer or anything that required a sprite to move with costumes, but I'm making a game now that requires this. So, would someone explain to me how to make the costumes do this. I already have the movement down like, forever if right arrow pressed make x -5 the costumes are all I need.
- Lone-Wolf
-
87 posts
How Can I Make a Sprite Change Costumes When It Moves?
I've been on scratch for a long time, but I never made a platformer or anything that required a sprite to move with costumes, but I'm making a game now that requires this. So, would someone explain to me how to make the costumes do this. I already have the movement down like, forever if right arrow pressed make x -5 the costumes are all I need.
Oh, so you're trying to figure out how to make it move with an animation using costumes? Well, you could say, “forever is right arrow pressed change x by -5 next costume.” Or you could set the costume to a variable, and constantly change that variable when the key is pressed. (But with a variable you'd need to make it so if it gets bigger or smaller than the amount of costumes, it goes back to one, so then it loops.)
As always, I hope this helps!

Last edited by Lone-Wolf (May 26, 2013 21:43:36)
- LittlePony
-
100+ posts
How Can I Make a Sprite Change Costumes When It Moves?
The sprite will go up, down,left, and right, so next costume wouldn't work. As for the variable, It wouldn't work out so well either…(I think)
- Lone-Wolf
-
87 posts
How Can I Make a Sprite Change Costumes When It Moves?
The sprite will go up, down,left, and right, so next costume wouldn't work. As for the variable, It wouldn't work out so well either…(I think)
Oh, I didn't know that part.

- Lone-Wolf
-
87 posts
How Can I Make a Sprite Change Costumes When It Moves?
One thing you could do is have scripts sepertated so they run at the same time. It would look like this:
(And of course, there would be the changing x or y part when a button is pressed, but in a seperate script.)
I hope this solved your problem!
When GF clicked
forever
if <button [up] pressed>
switch to costume [up1]
wait (0.5)
switch to costume [up2]
wait (0.5)
if <button [down] pressed>
switch to costume [down1]
wait (0.5)
switch to costume [down2]
wait (0.5)
And so on…
(And of course, there would be the changing x or y part when a button is pressed, but in a seperate script.)
I hope this solved your problem!
Last edited by Lone-Wolf (May 26, 2013 22:27:56)
- dracae
-
1000+ posts
How Can I Make a Sprite Change Costumes When It Moves?
Can you link what you have so far?
Thanks!
Thanks!

- Lone-Wolf
-
87 posts
How Can I Make a Sprite Change Costumes When It Moves?
Can you link what you have so far?
Thanks!
Yes, that would be helpful. It always is, because then we could see your problem.
- JayZX535
-
62 posts
How Can I Make a Sprite Change Costumes When It Moves?
It's pretty tough to explain here, however I have made a project like this before. Feel free to analyze what I have and even use my system, but just give credit in the notes if you use the exact project. I've been on scratch for a long time, but I never made a platformer or anything that required a sprite to move with costumes, but I'm making a game now that requires this. So, would someone explain to me how to make the costumes do this. I already have the movement down like, forever if right arrow pressed make x -5 the costumes are all I need.
http://scratch.mit.edu/projects/3063751/
Note: This method can be glitchy at times when changing directions
Happy scratching!
-Jay
- mwiedmann
-
100+ posts
How Can I Make a Sprite Change Costumes When It Moves?
I remixed JayZX535's project to use a timer based animation on the wolf. It keeps the code a little cleaner, allows you to adjust the animation speed with 1 variable, and allows your sprite to respond to input more quickly because it doesn't have all the “wait” statements.
Timer based wolf animation
You could do something similar with the grass on that project as well.
Timer based wolf animation
You could do something similar with the grass on that project as well.
- JayZX535
-
62 posts
How Can I Make a Sprite Change Costumes When It Moves?
^This is the updated method of my original project, and is actually my preferred method as well. Thanks for re-mixing, because I didn't really have any examples for it yet! And yeah, from what I've found, this method is pretty safe/reliable (unless you have multiple sprites running on the arrow keys at once because then you get lag, but that's generally not a problem). I remixed JayZX535's project to use a timer based animation on the wolf. It keeps the code a little cleaner, allows you to adjust the animation speed with 1 variable, and allows your sprite to respond to input more quickly because it doesn't have all the “wait” statements.
Timer based wolf animation
You could do something similar with the grass on that project as well.
- power784
-
4 posts
How Can I Make a Sprite Change Costumes When It Moves?
i could really use some help too, because.. http://scratch.mit.edu/projects/17377323/ happens
- loganmoose
-
1 post
How Can I Make a Sprite Change Costumes When It Moves?
i need help making a game where you move and animate at the same time without the screen moving. the best results i got were a really long delay between animation strings. here is the project http://scratch.mit.edu/projects/24837636/
- Just_A_Dream
-
36 posts
How Can I Make a Sprite Change Costumes When It Moves?
You do this:
when flag is clicked
move ___ steps
when flag is clicked
switch to next costume
when flag is clicked
move ___ steps
when flag is clicked
switch to next costume
- Kuesopop
-
100+ posts
How Can I Make a Sprite Change Costumes When It Moves?
I've been on scratch for a long time, but I never made a platformer or anything that required a sprite to move with costumes, but I'm making a game now that requires this. So, would someone explain to me how to make the costumes do this. I already have the movement down like, forever if right arrow pressed make x -5 the costumes are all I need.
Oh, so you're trying to figure out how to make it move with an animation using costumes? Well, you could say, “forever is right arrow pressed change x by -5 next costume.” Or you could set the costume to a variable, and constantly change that variable when the key is pressed. (But with a variable you'd need to make it so if it gets bigger or smaller than the amount of costumes, it goes back to one, so then it loops.)
As always, I hope this helps!
X value = -5
That's left not right lol.
- pickleoink
-
6 posts
How Can I Make a Sprite Change Costumes When It Moves?
make another script that says
- ILuvNintendo
-
7 posts
How Can I Make a Sprite Change Costumes When It Moves?
I want to know to because when I try
It doesn't work
- Discussion Forums
- » Help with Scripts
-
» How Can I Make a Sprite Change Costumes When It Moves?