Discuss Scratch

WTayler
New Scratcher
3 posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

So my sprite has multiple costumes for when it's running and for some reason I can't pin down how to make it move while switching through the costumes every time I press either right arrow key, or left arrow key.


So far here is my program for define_run:
define run
if <(char:move) = [1]> then 
point towards [sensor_right v]
switch costume to <(costume #) = [15]>
repeat until <not <key [right arrow v] pressed?>>
if <(costume #) = [28]> then
switch costume to <(costume #) = [15]>
wait (0.1) secs
else
if <(costume #) < [14]> then
switch costume to <(costume #) = [15]>
else
switch costume to ((costume #) + [1])
change x by [5]
wait (0.1) secs
end

end

else

end
georgeskey
Scratcher
100+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

The booleans essentially only report true or false (other then the last one, which changes the costume num by 1; it's a reporter, not a boolean) so you're essentially saying “switch costume to true” or “switch costume to false”…
WTayler
New Scratcher
3 posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

But earlier one when I used the same script, it switch the costume by it's currently set costume by 1. I want it to do that but move as well in an orderly fashion. Something like if all the booleans are false, then its repeatedly activates this until one of these are true.
deck26
Scratcher
1000+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

WTayler wrote:

But earlier one when I used the same script, it switch the costume by it's currently set costume by 1. I want it to do that but move as well in an orderly fashion. Something like if all the booleans are false, then its repeatedly activates this until one of these are true.
The booleans are fine in the if blocks but you don't want them in the switch costume blocks.
WTayler
New Scratcher
3 posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

Well thank you both for fixing my error, but it still doesn't move.
mstone326
Scratcher
1000+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

Can you share your project so we can see if there are any other scripts that are conflicting. It makes it much easier than just guessing at what the issue is.
crisostimo
Scratcher
500+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

I put this in a Scratch beginners tutorial. You can see the project here:

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

Then in the notes it has a bunch of youtube videos where I explain how it works if you are interested.

In your case you would follow the example of starting the walking animation using a broadcast like in my project, but then stop the animation when the key was no longer pressed.
tigerstar-
Scratcher
1 post

How do I make a sprite change costume almost each time it moves when it has more than one costume?

UMMM HELP ME
xMystic416
Scratcher
100+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

tigerstar- wrote:

UMMM HELP ME
Hi! Next time, please don't necropost. This is an old topic. If you need help, make your own one. Thanks!
itsmesupermicrowave
Scratcher
1 post

How do I make a sprite change costume almost each time it moves when it has more than one costume?

i want this
when this sprite clicked
if <> then
switch costume to [ 2]
else
switch costume to [ 3]end
DerpyHead0
Scratcher
1000+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

itsmesupermicrowave wrote:

i want this
when this sprite clicked
if <> then
switch costume to [ 2]
else
switch costume to [ 3]end
please don't necropost, this thread is 2 years old. if you want help with something create a new thread
imAFK
Scratcher
12 posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

when green follow clicked
say [thanks] for (2) secs
Merry_Kitten1212
Scratcher
2 posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

when green flag clicked
go to x: (?) y: (?)
repeat (?)
wait (?) secs
next costume
end
The_Imaginarium
Scratcher
1000+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

Merry_Kitten1212 wrote:

when green flag clicked
go to x: (?) y: (?)
repeat (?)
wait (?) secs
next costume
end
Please refrain from necroposting on old topics.
https://scratch.mit.edu/discuss/topic/355062/

Last edited by The_Imaginarium (May 8, 2021 20:04:35)

han614698
Scratcher
1000+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

Harakou
Scratcher
1000+ posts

How do I make a sprite change costume almost each time it moves when it has more than one costume?

Merry_Kitten1212 wrote:

when green flag clicked
go to x: (?) y: (?)
repeat (?)
wait (?) secs
next costume
end
Hi! Thank you for offering your help, but this thread is pretty old - I don't think it's relevant anymore. When you respond to a topic, please make sure it's recent and the original poster still needs an answer. Thanks!

Powered by DjangoBB