YES, THIS IS IN AS2. I’m just much faster at it.
Here’s a little platforming engine I’ve been messing with, intended to handle any shape of freely drawn terrain by using hitTest(point) against several points relative to a rectangle (the player). I’m not having any specific problems, but there’s a lot of messiness in the sprite’s behavior.
Arrow keys to move and jump. Check it out here: http://megaswf.com/s/2449612
For some reason MegaSWF can’t get dimensions right so try hitting “Play flash full screen” there.
I have the rectangle go transparent when it’s in its ‘air’ state and solid for the ‘ground’ state. So I’m not seeing anything that really BREAKS the rules here, but it behaves strangely when confronted with certain situations. Situations which aren’t that rare, but I can’t identify. For example, sometimes when the sprite should just be standing still, it jitters up and down rapidly. Sometimes (usually on a ledge) it switches every frame between its ground and air states. And sometimes it just jerks farther than it should; I know this is due to the ‘while’ loops for collision correction, but the way I have the sprite move each frame, I didn’t think it was possible for it to ‘embed’ itself in the terrain far enough to trigger them more than a few times.
So, does anyone have any ideas for how to smooth it out?
Code on Player MovieClip:
5 edits later…
Okay, I can’t figure out textile formatting for big blocks of code so I’m just pasting it here:
I hope it’s all pretty clear, I commented as much as I thought wasn’t obvious. Note that the only code anywhere else is concerned with moving the camera; all that matters otherwise is that the parent MC contains another child MC called “terrain.” So you can easily test this code in AS2 in your own FLA if you wish.