Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How Can I Make a Sprite Change Costumes When It Moves?
- LittlePony
-
Scratcher
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
-
Scratcher
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
-
Scratcher
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
-
Scratcher
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
-
Scratcher
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
-
Scratcher
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
-
Scratcher
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
-
Scratcher
62 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.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.
http://scratch.mit.edu/projects/3063751/
Note: This method can be glitchy at times when changing directions
Happy scratching!
-Jay
- mwiedmann
-
Scratcher
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
-
Scratcher
62 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.^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).
Timer based wolf animation
You could do something similar with the grass on that project as well.
- power784
-
New Scratcher
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
- SCRATHCREATOR950
-
Scratcher
12 posts
How Can I Make a Sprite Change Costumes When It Moves?
when green flag clicked
forever
glide (1) secs to x: (RANDOM NUMBER) y: (RANDOM NUMBER)
next costume
end
- loganmoose
-
Scratcher
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
-
Scratcher
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
- olesijk1
-
Scratcher
2 posts
How Can I Make a Sprite Change Costumes When It Moves?
d
when green flag clicked
forever
if key right arrow pressed then
wait 0.2 seconds
next costume
change x by 10
- olesijk1
-
Scratcher
2 posts
How Can I Make a Sprite Change Costumes When It Moves?
when green flag clicked
forever
if <key [ v] pressed?> then
wait secs
next costume
change x by ()
end
end
- Kuesopop
-
Scratcher
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
-
Scratcher
6 posts
How Can I Make a Sprite Change Costumes When It Moves?
make another script that says
when green flag clicked
forever
switch costume to [costume 1]
wait (.1) secs
switch costume to [costume 2]
wait (.1) secs
end
- upupup3
-
Scratcher
4 posts
How Can I Make a Sprite Change Costumes When It Moves?
This is how
[scratchblocks]
when [ v] key pressed
[/scratchblocks][scratchblocks]
forever
if <key [ v] pressed?> then
point in direction ( v)
move () steps
next costume
end
end
[/scratchblocks]
- ILuvNintendo
-
Scratcher
7 posts
How Can I Make a Sprite Change Costumes When It Moves?
I want to know to because when I try
when green flag clickedIt doesn't work
set rotation style [left-right v]
define Controls
if <key [right arrow v] pressed?> then
point in direction (90 v)
next costume
move (10) steps
if <(costume #) = [ 1]> then
switch costume to [2 v]
end
end
- Discussion Forums
- » Help with Scripts
-
» How Can I Make a Sprite Change Costumes When It Moves?
