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