easing movement

Get help using Construct 2

Post » Sat Mar 30, 2013 10:56 am

I've been trying to implement my own tweening/easing movements based off robert penners equations.

I've started with the simplest linear movement and got it working but the movement time doesn't work how i expect. I'm not sure if it's my code which is wrong, how i've implemented the formula, or my understanding of constructs ticks and time.

I've set the duration to 1000 milliseconds which is 1 second. The function is updated every 0.001 second which adds 1 to the objects elapsed time, 0 being the beginning and 1000 (duration) being the end, so 500 would be the half way point.

Could someone please take a look and see where i'm going wrong.

Much appreciated.

construct file

B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Sat Mar 30, 2013 1:51 pm

I recall there's already a easing behavior called EaseTween. It's also based off robert penners equations. Check it out: http://www.scirra.com/forum/behavior-easetween_topic53288.html
B
21
S
5
G
5
Posts: 58
Reputation: 5,232

Post » Sat Mar 30, 2013 1:57 pm

you can always use lerp
... Easing in the movement of an object

lerp(Object.X,Desired.X,dt(multiplied)10)
will make an object X smoothly ease toward the desired X
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Sat Mar 30, 2013 2:08 pm

Thanks for your replies guys, i know about the behaviour but wanted to have ago coding it myself. It might be my MMF background making me wary of using 3rd party stuff as developers disappear and things never get updated.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], DiabloOvermind, emoticon, odiusfly, randomly and 20 guests