by omp123 » Sun Jun 29, 2014 10:45 am
Can't preach what Ivan said any harder; don't vectorize your backgrounds. Your platforms should be invisible (or covered-up) plain rectangles/simple shapes with bitmap graphic overlays to cover up the raw surfaces where the hitbox detection is actually made. Also, the vectored character sprites should not be hitboxes themselves; make separate invisible hitbox squares that follow the character that do all the platform and combat detection.
Finally, for the core platforming engine, you have to think ahead if you want to avoid glitchy platforms. You can't just say "if my character is right on top of the ground, stop falling", because if you land too hard and flash (inevitably) makes you fall through the first few pixels of the top of the platform, your code is fucked and you're either stuck in the ground, wall, or falling right through, because you're technically not "right on top of the ground." Some engines remedy this by detecting the overlap and commanding the object to move upwards or sideways until you're free from the overlap, but that's reactive, and a good engine should be proactive. So you need to code your collision detection to "anticipate" the ground or wall. You need to tell it to "check to see if the ground is at least 5 pixels away, and if so, move down one pixel at a time until the ground is one pixel below your character, then stop falling". (Despite moving one pixel at a time at that rate, it shouldn't slow down your fall. Also make the distance of that "ground check" relative to the rate of falling. If max gravity is 15 pixels while falling, make the detection 15 pixels.) I forget if flash uses pixels as its unit of distance measurement, but this is the mindset you need to avoid falling through the floor or wall. If you're 5 pixels away from the ground and traveling at a speed of 10 pixels, you're going to clip right through the ground in that 5 pixel gap.