Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Making your sprite move smoothly
- Mr-Mathmatical
-
95 posts
Making your sprite move smoothly
We all used to do it, and some of us still do it now. I'm talking about movement, and how to make it look smooth. Many of you have seen (or made) projects where you press and hold a key to move, but the movement is in little chunks:
This means the sprite can move, but it kinda goes forward, wait, forward, wait.
I have a solution to this:
This means that when you press the key, it will move and not stop until you let go of the key. It makes the movement much smoother!
I hope this helped you!
Scratch on everyone!
when [Up Arrow] key pressed
move (10) steps
This means the sprite can move, but it kinda goes forward, wait, forward, wait.
I have a solution to this:
when green flag clicked
forever
if <key [Up Arrow] pressed?> then
move (10) steps
end
end
This means that when you press the key, it will move and not stop until you let go of the key. It makes the movement much smoother!
I hope this helped you!
Scratch on everyone!
- Spontaneous08
-
100+ posts
Making your sprite move smoothly
A: This in the the wrong forum
B: Use this instead
B: Use this instead
when green flag clicked
forever
if <key [up arrow v] pressed?> then
change y by (10)
end
end
- deck26
-
1000+ posts
Making your sprite move smoothly
Neither of these is particularly new though!
- Mr-Mathmatical
-
95 posts
Making your sprite move smoothly
Neither of these is particularly new though!
Yes but I've seen many projects like that and I'm just trying to let people know that this is the better way to do it.
- JavierR100
-
500+ posts
Making your sprite move smoothly
Smooth moving:
when gf clickedif you want to move it, use the variables instantead of “go to x, y” or “change x/y”:
forever
go to x: (((x) / (2)) + ((x position) / (2))) y: (((y) / (2)) + ((y position) / (2)))
end
when gf clicked
forever
if <key [left arrow v] pressed?> then
change [x v] by (-5)
end
if <key [right arrow v] pressed?> then
change [x v] by (5)
end
if <key [up arrow v] pressed?> then
change [y v] by (5)
end
if <key [down arrow v] pressed?> then
change [y v] by (-5)
end
end
- Mr-Mathmatical
-
95 posts
Making your sprite move smoothly
Oh thanks! I never even knew that was a thing! I'll use that instead Smooth moving:when gf clickedif you want to move it, use the variables instantead of “go to x, y” or “change x/y”:
forever
go to x: (((x) / (2)) + ((x position) / (2))) y: (((y) / (2)) + ((y position) / (2)))
endwhen gf clicked
forever
if <key [left arrow v] pressed?> then
change [x v] by (-5)
end
if <key [right arrow v] pressed?> then
change [x v] by (5)
end
if <key [up arrow v] pressed?> then
change [y v] by (5)
end
if <key [down arrow v] pressed?> then
change [y v] by (-5)
end
end

- potatosurprise23
-
27 posts
Making your sprite move smoothly
Hello to make sprites move smoothly without stoping is
or
The number needs to be 6 to make it run smoothly
when [ v] key pressed
repeat until <not <>><key [ v] pressed?>
change y by (6)
or
change x by (6)
The number needs to be 6 to make it run smoothly
Last edited by potatosurprise23 (July 1, 2021 13:19:36)
- Discussion Forums
- » Help with Scripts
-
» Making your sprite move smoothly