我有两个圆形物体。我试图在圆圈触摸时立即检测到。当一个圆圈到达另一个圆圈的中心时,轨迹会检测到碰撞,但我希望一旦圆圈接触就会检测到碰撞。
我的两个符号是coin_mc和mugbounds_mc。
function checkHitArea(evt:Event)
{
if (coin_mc.hitTestPoint(mugbounds_mc.x,mugbounds_mc.y, true)) {
coin_mc.x=-1;
coin_mc.y=-1;
trace("Hit Mug"); // Is triggered when coin_mc reaches center of mugbounds_mc
}
else
{
trace("Didn't Hit Mug");
}
}
答案 0 :(得分:1)
试试这个:
addEventListener(Event.ENTER_FRAME, checkHitArea)
function checkHitArea(e:Event)
{
a.x += 2;
if (a.hitTestPoint(b.x,b.y, false))
{
// do our in-circle check
if((a.x - b.x) * 2 + (a.y - b.y) * 2 <= (a.width/2 + b.width/2) * 2)
{
trace("hit");
}
}
else
{
trace("Didn't Hit Mug");
}
}
我将您的影片剪辑重命名为a和b。