0
即时尝试在我的游戏中进行碰撞检测,本教程使用hitTestPoint,这里是代码的一部分,如果任何人都可以提供帮助,将无法工作。地面只是一个街区影片剪辑和播放器,以及玩家:1061:通过静态类型的引用调用可能未定义的方法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.
谢谢你的人谁花时间阅读本!
感谢您抽空回复的时间,但现在我得到这个错误: '场景1,图层“行动”,第1帧,8号线\t 1180:调用可能未定义的方法ground.' 我导入了flash.display.MovieClip;但它仍然不会工作 我真的很感谢你的帮助! – user1798964
似乎某物正试图调用一个不是函数的函数。类似于'foo.ground()'确保你正在调用已定义的方法。 –
对不起,我应该怎么做才能制定出明确的方法,地面是舞台上的动画片段,只是一个街区,我放置了多个场地来为我的游戏制作舞台,谢谢哟帮助 – user1798964