1
我有麻煩我的ActionScript 3代碼,它給了我這個錯誤:類型錯誤:錯誤#2007:AS3
TypeError: Error #2007: Parameter hitTestObject must be non-null. at flash.display::DisplayObject/_hitTest() at flash.display::DisplayObject/hitTestObject() at MethodInfo-8()
這是代碼:
//Kills you if you touch an Enemy
addEventListener(Event.ENTER_FRAME, checkCollision);
function checkCollision(e:Event):void
{
if (square.hitTestObject(newEnemy)){
//removeEventListener(Event.ENTER_FRAME, checkCollision);
removeEventListener(Event.ENTER_FRAME,update);
stage.removeEventListener(KeyboardEvent.KEY_DOWN,jump);
removeChild(square);
init();
}
}
正如錯誤提到的,你的'newEnemy'不能爲空...... – akmozo