Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smooth out sprite motion in scratch

Tags:

mit-scratch

How can I smooth out animations in Scratch? Mainly, I want it such that when you press and hold the right arrow, it goes right without any noticeable jittering. Plus, scratch makes you wait a second to repeat when you hold an arrow. How can I smooth this stuff out?

like image 451
Guy Avatar asked Sep 01 '11 14:09

Guy


3 Answers

I know it's an old question. But in case somebody is looking for a solution, check out this scratch project: http://scratch.mit.edu/projects/276298/

Just add forever loop and inside this loop check if arrow key is pressed. If it is - move. This way you won't be dependent on keyboard repeat rate.

like image 82
Dima L. Avatar answered Sep 30 '22 13:09

Dima L.


With Scratch, you can get very smooth motion using Glide with long distances or intervals. However, the disadvantage of this method is that the Glide operation must finish before the sprite can do any sensing, such as edge or collision detection. This is often undesirable.

The small delay that you are talking about when you press a key, is actually directly tied to the repeat rate of your keyboard. When you press a key on your keyboard, that key event is sent, but then there is a small delay before the repeat kicks in. If you can find a way to change your system keyboard repeat rate, this would carry over into Scratch.

There is a limit to how much optimizing you can do in Scratch. It is, after all, a very basic(but very fun), entry-level programming environment. :)

like image 21
Stewbob Avatar answered Sep 30 '22 11:09

Stewbob


You could do until "arrow not pressed"

when arrow pressed repeat move (or glide) until not arrow pressed

then it will not check key pressing at set intervals, making the move smoother.

like image 25
boisvert Avatar answered Sep 30 '22 13:09

boisvert