0
我一直在AS3開發視頻gamish的東西。我有一個數組來繪製包含道路,火焰,完成門等的遊戲場。然後,我添加一個由玩家通過鼠標控制的MovieClip,並嘗試檢查與道路MovieClip的碰撞。多個HitTestObject ActionScript 3.0
但是,我不工作......它從來沒有跟蹤「進」。我在代碼中找不到任何錯誤 - 但你永遠無法確定... 你能幫助解決這個問題嗎?
謝謝你們!
下面是代碼:
Declarations:
public class Player extends MovieClip
{
public var player:MovieClip;
public var road:MovieClip;
public var finish:MovieClip;
public var fire:MovieClip;
public var sting:MovieClip;
public var map:Array = new Array();
數組初始化:
/* 1 ROAD
* 2 FINISH
* 3 FIRE
* 4 STRING
*/
public function Player():void
{
map = [ [ 1, 1, 3, 3, 3, 3, 3, 3, 1, 1 ],
[ 1, 1, 3, 4, 4, 4, 4, 3, 1, 1 ],
[ 1, 1, 3, 4, 4, 4, 4, 3, 1, 1 ],
[ 1, 1, 3, 3, 3, 3, 3, 3, 1, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ],
[ 1, 1, 3, 3, 3, 3, 3, 3, 1, 1 ],
[ 1, 1, 3, 4, 4, 4, 4, 3, 1, 1 ],
[ 1, 1, 3, 4, 4, 4, 4, 3, 1, 1 ],
[ 1, 1, 3, 3, 3, 3, 3, 3, 1, 1 ]
];
// 10 x 10 array
添加則hitTest功能:
addEventListener( Event.ENTER_FRAME, playerHitTest);
而則hitTest功能:
public function playerHitTest(e:Event):void
{
if (player.hitTestObject(road))
{
trace("IN");
}
}
PS:如果我使條件!player.hitTestObject(road)
,它總是跟蹤「IN」。
再次感謝!