Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Animation TweenChain for an Arc/Parabola?

Author
Message
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 1st Aug 2015 05:32
I'm trying to setup an animation of a frog leaping across the screen and would like to get a smooth arc/parabola motion. Any thoughts on the best way to do this? I thought somehow I should integrate sprite tweening with the CreateTweenChain.

Not real good with the math on this type of thing yet.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Aug 2015 10:20
You could try...

Apply a tween X for n seconds
Apply a tween chain with:
Tween Y for n/2 seconds with an ease out
Tween Y for n/2 second with an ease in

If there is a chance your leap will be interrupted then you can delete the tweens and take control again

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Uncle Martin
18
Years of Service
User Offline
Joined: 9th Jul 2006
Location: Tampa, Florida, USA
Posted: 2nd Aug 2015 07:09 Edited at: 2nd Aug 2015 07:10
I don't know much about you kids' tweening & such, but the math for parabolic projectile motion is not too hard. Recall in high school physics we learned that forward speed is constant & upward speed is decelerated by gravity until it becomes downward speed. So in code we simply fire off initial forward & vertical velocity & then each frame add the velocity to the positon to get the new position. We also add the accelerations to the velocities to get the new velocities. The following code illustrates all this. Sprite image attached. Space bar to jump & double-jump. Enjoy.



Code every line like it might be your last...
Someday it will be.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 19:39:04
Your offset time is: 2024-11-25 19:39:04