我试图在我的游戏中进行碰撞检测,而本教程使用的是 hitTestPoint,如果有人可以提供帮助,这是代码的一部分。地面只是一个块电影剪辑,播放器是,播放器:
stage.addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
if (ground.hitTestPoint(borat.x + leftBumpPoint.x,borat.y + leftBumpPoint.y,true))
{
trace("leftBumping");
leftBumping = true;
}
else
{
leftBumping = false;
}
if (ground.hitTestPoint(borat.x + rightBumpPoint.x,borat.y + rightBumpPoint.y,true))
{
trace("rightBumping");
rightBumping = true;
}
else
{
rightBumping = false;
}
if (ground.hitTestPoint(borat.x + upBumpPoint.x,borat.y + upBumpPoint.y,true))
{
trace("upBumping");
upBumping = true;
}
else
{
upBumping = false;
}
if (ground.hitTestPoint(borat.x + downBumpPoint.x,borat.y + downBumpPoint.y,true))
{
trace("downBumping");
downBumping = true;
}
else
{
downBumping = false;
}
}
我不断收到这些错误:
Scene 1, Layer 'actions', Frame 1, Line 37 1061: Call to a possibly undefined method hitTestPoint through a reference with static type Class.
Scene 1, Layer 'actions', Frame 1, Line 47 1061: Call to a possibly undefined method hitTestPoint through a reference with static type Class.
Scene 1, Layer 'actions', Frame 1, Line 57 1061: Call to a possibly undefined method hitTestPoint through a reference with static type Class.
Scene 1, Layer 'actions', Frame 1, Line 67 1061: Call to a possibly undefined method hitTestPoint through a reference with static type Class.
感谢任何花时间阅读本文的人!