因此,我有一個名爲hookLine
的影片剪輯,它從我的mainEngine
類中添加到舞臺上。此空的影片剪輯連接到我的fisherman
影片剪輯並曲線到我的playerHook
影片剪輯。它的加入並連接到該級,像這樣:HitTest在使用Graphics.lineTo時無法正常工作/ curveTo
在我mainEngine
功能循環:
playerHookLine();
則函數:
private function playerHookLine():void
{
//Add hook line to fisherman and playerhook
hookLine.graphics.clear();
hookLine.graphics.lineStyle(1);
hookLine.graphics.moveTo(fisherman.x, fisherman.y);
hookLine.graphics.curveTo(playerHook.x, playerHook.y, mouseX, mouseY);
}
現在我遇到的問題是每當我嘗試則hitTest hookLine
與一個名爲currentShark
的移動剪輯hitTest的作品,我得到了一個痕跡,但它不準確的時候,我彎曲我的鉤線兩側和currentShark
在舞臺上它自動hitTests並給出我的痕跡。所以基本上鯊魚甚至不必接觸實際的線條圖形。正當鯊魚加入舞臺時,它只是登記。
有沒有人有任何想法,爲什麼這是?
這裏是則hitTest功能是如何:
private function checkPlayerHitShark():void
{
//Loop through all sharks
for (var i:int = 0; i < aSharkArray.length; i++)
{
//Get current Shark in i loop
var currentShark:mcShark = aSharkArray[i];
//Check if shark is hittest with Hook
if (currentShark.hitTestObject(playerHook) || currentShark.hitTestObject(hookLine))
{
trace("Hook Hit Shark");
trace("hit LINE");
removePlayerLive();
//Destroy player
playerHook.destroyPlayerHook();
hookLine.destroyHookLine();
//Remove shark from array
aSharkArray.splice(i, 1);
//Add new Hook to stage
stage.addChild(playerHook);
stage.addChild(hookLine);
}
}
}
我的意思是說,將您的程序發佈爲.SWF文件並在Flash播放器中打開它。玩家本身將在頂部有一個菜單,您將看到「查看」按鈕,在該菜單中顯示重繪區域。我也要編輯我的帖子。 – E10
謝謝你的所有信息。對此,我真的非常感激。你也是對的,無論我移動它,線條都有一個巨大的矩形框。 – Nathan
哦,好吧,我明白了。我會繼續閱讀你現在寄給我的那些文章。那麼生病就能把這個區域縮小到hookLine? – Nathan