Discuss Scratch

cream_felonious
New Scratcher
5 posts

easing with movement

I want to learn how to make those smooth paced movements
ease in, ease out, ease in out and that stuff
easings! i found a website page that talks about that stuff, not scratch related tho it was for other programming languages
i think i like the “cubic” easings more
so how do i do that?
yippymishy
Scratcher
100+ posts

easing with movement

Most of the easing functions on this website can be converted to Scratch relatively easily using the math function given there!

For example, the easeOutCubic function has this math function:
function easeOutCubic(x: number): number {
return 1 - Math.pow(1 - x, 3);
}

We can remove the first and third lines first, plus “return” and all the semicolons:
1 - Math.pow(1 - x, 3)

Now we can start converting the function to Scratch! “1 - ” at the beginning is easy:
((1) - ())

And “Math.pow” means an exponent which doesn't exist in Scratch, but we can just use repeated multiplication, so here is the completed math:
((1) - ((((1) - (x)) * ((1) - (x))) * ((1) - (x)))

To use it, make a script like this!
when green flag clicked
set [x v] to [0]
repeat (100)
set x to (((1) - ((((1) - (x)) * ((1) - (x))) * ((1) - (x)))) * (50)) //can be any block! *50 = 50 steps
change [x v] by [0.01]
end

This post turned out longer than I thought it would be lol

Last edited by yippymishy (Sept. 14, 2023 13:48:23)

cream_felonious
New Scratcher
5 posts

easing with movement

What about in-out easing? I want to use easeInOutQuint
Also I want the movement to end in a certain y-coord. Say, 20.
It would be convenient to have a set time for the movement to occur. I want it to last for 1.5 seconds.

Last edited by cream_felonious (Dec. 5, 2023 19:58:05)

faindas
New Scratcher
2 posts

easing with movement

easeInOutQuint:
https://easings.net/#easeInOutQuart

Powered by DjangoBB