我的ActionScript 3代码有问题,它给了我这个错误:
TypeError:错误#2007:参数hitTestObject必须为非空。显示::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();
}
}发布于 2015-11-12 17:46:57
似乎没有定义newEnemy变量。
https://stackoverflow.com/questions/33628350
复制相似问题