PDA

View Full Version : A jump method that actually works????


phinnycupcakes
12-11-2008, 07:14 PM
Hi! So I've been going around trying to get some help making a jump method for my 2D sidescroller game that i'm working on... EVERY SINGLE TIME, OUT OF EVERY HELP SITE I GO TO, they always give me something with a Key UP.isDown()...<< while( isDown ) >>???? I DONT WANT MY CHARACTER TO BE FLYING! I want it to be just a single jump that lands on a given surface marked as "land" (why land and not a specific X coordinate? because I want there to actually be platforms.)

I've got left and right mastered and enemies and everything.. All I need is just SOME help for an actual jump method that people would use...

THANK YA!
Phinny Cupcakes

EDIT

My code for moving left and right involves using Key.isDown in functions that I later put into the function OnEnterFrame... So if you could think of a single method I could easily type into the onenterframe function... that would be most awesome..

And I'm not too experienced with listeners.. in fact I've never used them before... only heard and read about them.

rrh
12-12-2008, 05:41 AM
The landing is trickier than the jumping.

For jumping, you have a dy variable for the vertical speed. While running normally, it's 0, but when you jump, change it to dy=-jumpSpeed. While flying through the air, apply dy+=gravity until it lands and change it to dy=0 again.

So the tricky part is knowing when you're touching ground and when you should be falling.

phinnycupcakes
12-12-2008, 02:02 PM
Yeah I guess that is an issue. I was thinking of just using hittests to figure out if the guy is landing on a platform... but what if the guy hits the platform from the side? the script is still going to execute. =(

Again.. how would I even initiate this script?

Hackor Pickel
12-12-2008, 06:49 PM
http://www.kirupa.com/developer/mx2004/platform_game.htm
i think this is what you're looking for, hope i helped =]

phinnycupcakes
12-12-2008, 07:23 PM
http://www.kirupa.com/developer/mx2004/platform_game.htm
i think this is what you're looking for, hope i helped =]

You are quite the friend.. and I <3 you forever.

Thank you for the help!!!!! =DDDDDD

Hackor Pickel
12-13-2008, 05:10 PM
no problem :D glad i can help for a change =]