I’m working on a simple collision detection function, but I’m having a problem. It can detect when the circle, mc_ball, is intersecting platformVar, mc_platform%i%, but often the circle is halfway through the platform by the time the hitTest recognizes the collision. I understand why this is happening, and to compensate, I’d like to add a “cushion” to the rectangle to improve hitTest’s chance of detecting the overlap before the circle goes down too far. I think I have the right idea to do this, but could somebody help me out with the syntax? Or, if there is a better way to solve the problem, lead me in the right direction? Thanks a bunch.
platformVar = “mc_platform” + String(i);
//ymax, ymin, xmax, xmin ???
var platformBounds:Object = [this[platformVar]._y + this[platformVar]._height + cushionV, this[platformVar]._y - cushionV, this[platformVar]._x + this[platformVar]._width + cushionH, this[platformVar]._x - cushionH];
if (mc_ball.hitTest(platformBounds)){
airborne = false;
}