Various ease in / ease out through functions

Get help using Construct 2

Post » Sat Apr 13, 2013 8:31 pm

I saw this link:

Easing Equations

or

Robert Penner Easing Equations

and was trying to get the quadratic ease out to work but couldn't figure out a certain section of code marked in bold :

// quadratic easing out - decelerating to zero velocity
Math.easeOutQuad = function (t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
};

How do I translate 't/=d' to C2? I'm basically using trying to move a ball across the screen that eases out to zero velocity.

[Edit] I changed the title from 'Quadratic Easing' to 'Various ease in / ease out through functions'. While I was looking for a single form of ease out, the mighty Yann returned many types of ease ins/outs via functions with an excellent capx example file.
bon4ire2013-04-19 14:33:46
B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sat Apr 13, 2013 8:44 pm

t /= d means t = t / d. basically a shortcut for 'set t to t / d'.

It looks like you copied the function over wrong - the t /= d comes in a separate line on the linked website. I don't see why you put it into the algorithm.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Apr 13, 2013 8:59 pm

Check out easytween plugin too, has lots of easing functions in easy to use form!
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Apr 13, 2013 9:49 pm

I copied the info from the second link which shows it as being part of the code.

Strange that it's separate in the first link.

B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sat Apr 13, 2013 9:51 pm

[QUOTE=vee41] Check out easytween plugin too, has lots of easing functions in easy to use form![/QUOTE]

Was trying to avoid using a plugin.
B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sat Apr 13, 2013 9:57 pm

A more 'traditional' way to do ease out is to use this formula:

set x to lerp(self.x,destinationx,dt * factor)

same for y.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Apr 13, 2013 10:38 pm

Thanks @sqiddster

I was hoping to create a function sheet collection of ease ins and outs based on Robert Penner's codes and to mimmic the sample screen on the first link.

B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sun Apr 14, 2013 1:58 am

demo
capx

(Though it wouldn't be hard to make a plugin for that)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Apr 14, 2013 2:03 am

Holy smokes @yann that's beautiful!bon4ire2013-04-18 17:56:48
B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sun Apr 14, 2013 2:06 am

Just rewrote the thing as in the first link o.o
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: MarkThomas and 0 guests