I’m making a side-scroller platformer and I have the level all as one movie clip. Inside the level I have the hero mc. OnEnterFrame in order to check if they guys on the ground, or how close to the ground he is I run this getFloor() function I made. It works, but it refuses to return the correct value 100% of the time. I don’t know how to explain it without showing. What it appears to be doing is to find the floor when going uphill but when the floor moves any lower than it was before, it refuses to update. The yellow cross is where it detects the floor at. [Games running at 10 frames per second for debugging purposes.] [Everything with a dark outline is should is a part of the level everything else is just another aesthetic movie clip called level_underlay]
https://dl.dropbox.com/u/7032543/title2.swf
public function getFloor(mob:MovieClip):Number{
removeChild(mob);//Removes the mc from the stage in order to make sure its not hittestpointing the mc.
var i:Number;
for(i=mob.y;i<=height;i+=0.5){//I have it start at the mc's y and not his y+height because the ground might be only half a step up
var point:Point=this.localToGlobal(new Point(mob.x,i));
if(this.hitTestPoint(point.x,point.y,true))break;
}
addChild(mob);
return i;
}