Smooth the movement of sprites in scratches

How to smooth animation in Scratch? Basically, I want it so that when you press and hold the arrow to the right, it goes straight without any noticeable jitter. In addition, a scratch will make you wait a second to repeat when you hold the arrow. How can I flatten this stuff?

+6
source share
5 answers

I know this is an old question. But if someone is looking for a solution, look at this project from scratch: http://scratch.mit.edu/projects/276298/

Just add a forever loop and inside this loop check if the arrow key is pressed. If it is, move. This way, you will not be affected by the keyboard repetition rate.

+3
source

With Scratch, you can get very smooth movement using Glide at great distances or intervals. However, the drawback of this method is that the Glide operation must end before the sprite can make any sensations, such as edge detection or collision. This is often undesirable.

The slight delay that you talk about when you press a key is actually directly related to the repetition rate of your keyboard. When you press a key on the keyboard, this key event is dispatched, but then there is a slight delay before it repeats. If you can find a way to change the repetition rate of your system keyboard, this will be ported to Scratch.

There is a limit to how many optimizations you can make in Scratch. This is, after all, a very simple (but very funny) entry-level programming environment. :)

+2
source

You can do until "arrow is pressed"

when pressing the arrow, repeat (or slide) the repetition until the arrow is pressed

then it will not check keystrokes at set intervals, making the movement smoother.

+2
source

You can do it:

 When flag pressed forever if (right arrow pressed?) then change xs by 1 xs = xs * 0.8 change x by (xs) 

This checks every time if the right arrow is pressed, and if so, then it changes the xs variable by one. Later, he multiplies xs by 0.8, so the value of the spectacle breaks up.

Then it changes the sprite x to var xs .

+1
source

One way to do this is to use variable and custom blocks so that the arguments smooth the movement. Add a variable called speed x and use the perpetual change of X to speed X. I have no snapshots or examples, but you can use scripts in the user block to glide smoothly.

0
source

Source: https://habr.com/ru/post/896414/


All Articles