在函數hitWall中,hitTestObject在玩家擊中牆時正在工作。我在閃光舞臺上有牆壁,命名爲wall,wall2,wall3,wall4。使用相同的概念,我放置了其他影片剪輯(樹)並命名它們:tree1,tree2等....等等。hitTestObject(AS3)錯誤:訪問未定義的屬性
我收到一條錯誤消息:訪問未定義的屬性樹。
wall.addEventListener(Event.ENTER_FRAME, hitWall);
tree.addEventListener(Event.ENTER_FRAME, hitTree);
// function hitWall --------------------------------------------------------------
function hitWall(event:Event):void {
if (player_ary[me].hitTestObject(wall)) {
player_ary[me].y+=6;
} else if (player_ary[me].hitTestObject(wall2)) {
player_ary[me].y-=6;
} else if (player_ary[me].hitTestObject(wall3)) {
player_ary[me].x+=6;
} else if (player_ary[me].hitTestObject(wall4)) {
player_ary[me].x-=6;
}
}
// function hitWall --------------------------------------------------------------
function hitTree(event:Event):void {
if (player_ary[me].hitTestObject(tree)) {
player_ary[me].y+=6;
} else if (player_ary[me].hitTestObject(tree2)) {
player_ary[me].y-=6;
} else if (player_ary[me].hitTestObject(tree3)) {
player_ary[me].x+=6;
}
}