# hitTest with Padding

**URL:** <https://forum.kirupa.com/t/hittest-with-padding/209765>\
**Category:** programming\
**Created:** [December 12, 2006, 6:42am UTC](https://forum.kirupa.com/t/hittest-with-padding/209765 "2006-12-12T06:42:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickcherryjiggz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nickcherryjiggz/32/2107_2.png) [@nickcherryjiggz](https://forum.kirupa.com/u/nickcherryjiggz)\
**Post date:** [December 12, 2006, 6:42am UTC](https://forum.kirupa.com/t/hittest-with-padding/209765/1 "2006-12-12T06:42:20Z")

</div>

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;  
}
