Discuss Scratch

flabore
New to Scratch
8 posts

Making a Sprite move with different costumes

So I'm making a pixel game that requires sprites to move.

I'm able to make the sprite move to where I want to by using glide, but I still need help because they switch between costumes to make them look like they are “walking”.

What I need is for when someone clicks an arrow button they go right, left, up or down while still rotating between costumes
Thiplol
Scratcher
100+ posts

Making a Sprite move with different costumes

when [ left arrow] key pressed
change x by (10)
next costume


flabore
New to Scratch
8 posts

Making a Sprite move with different costumes

Thiplol wrote:

when [ left arrow] key pressed
change x by (10)
next costume


I tried that but it's not moving when I press the key.

I'm having it loop through three different costumes with 0.1 second intervals in between

Does this look okay
when [left v] key pressed
change x by (-240)
forever

switch costume to [1 v]
wait (.1) secs
switch costume to [2 v]
wait (.1) secs
switch costume to [3 v]
wait (.1) secs
end
jamy_hensley
Scratcher
100+ posts

Making a Sprite move with different costumes

Put the
change x by (10)
inside the
forever

end
loop

My Projects

4 Pics 1 Word
jamy_hensley
Scratcher
100+ posts

Making a Sprite move with different costumes

I forgot to mention: change the x factor after each wait sequence

My Projects

4 Pics 1 Word
jamy_hensley
Scratcher
100+ posts

Making a Sprite move with different costumes

Discard what I said above. Use two scrips in parallel
When left clicked, glide for 1 second.
When left clicked use the timer. Set variable to the timer. Repeat change costume, wait 0.1 sec until variable - timer > 1

My Projects

4 Pics 1 Word
flabore
New to Scratch
8 posts

Making a Sprite move with different costumes

jamy_hensley wrote:

Discard what I said above. Use two scrips in parallel
When left clicked, glide for 1 second.
When left clicked use the timer. Set variable to the timer. Repeat change costume, wait 0.1 sec until variable - timer > 1
Can you set that up in the script in the scratch format? I'm not quite following.

Thanks
Ahsoka130
Scratcher
1 post

Making a Sprite move with different costumes

Thiplol wrote:

when [ left arrow] key pressed
change x by (10)
next costume
How do you get it to move right though????
mstone326
Scratcher
1000+ posts

Making a Sprite move with different costumes

Ahsoka130 wrote:

Thiplol wrote:

when [ left arrow] key pressed
change x by (10)
next costume
How do you get it to move right though????

Look at the date of this original post. It is from 2015. If you have a question create a new topic so the forums can help instead of digging up a 2 year old thread.

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
RAB2004
Scratcher
30 posts

Making a Sprite move with different costumes

flabore wrote:

Thiplol wrote:

when [ left arrow] key pressed
change x by (10)
next costume


I tried that but it's not moving when I press the key.

I'm having it loop through three different costumes with 0.1 second intervals in between

Does this look okay
when [left v] key pressed
change x by (-240)
forever

switch costume to [1 v]
wait (.1) secs
switch costume to [2 v]
wait (.1) secs
switch costume to [3 v]
wait (.1) secs
end
The Problem with this code
is that it only gets runned once
unaware until it is pressed again.
Even though it seems like its
moving.
gtoal
Scratcher
1000+ posts

Making a Sprite move with different costumes

jamy_hensley wrote:

Discard what I said above. Use two scrips in parallel
When left clicked, glide for 1 second.
When left clicked use the timer. Set variable to the timer. Repeat change costume, wait 0.1 sec until variable - timer > 1
Wow. Does that work? I've never tried it, just assumed it wouldn't.

Even if that rather clever hack works, what the poster should really do is NEVER USE GLIDE. Recode the scripts to do explicit movements.

Glide is evil and messes you up. :-)
footsocktoe
Scratcher
1000+ posts

Making a Sprite move with different costumes

gtoal wrote:

jamy_hensley wrote:

Discard what I said above. Use two scrips in parallel
When left clicked, glide for 1 second.
When left clicked use the timer. Set variable to the timer. Repeat change costume, wait 0.1 sec until variable - timer > 1
Wow. Does that work? I've never tried it, just assumed it wouldn't.

Even if that rather clever hack works, what the poster should really do is NEVER USE GLIDE. Recode the scripts to do explicit movements.

Glide is evil and messes you up. :-)


Parallel scripts work for glides and animations. The internal code for a glide is a series of moves, I would think.

However, you don't need to use the timer for your animation, just…

repeat (10)
next costume
wait (.1) secs
end

if it is a one second glide.


SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!

Powered by DjangoBB