I’m having a problem in my side-scrolling game where when each “prey” gets eaten by the character, they are counting multiple times, causing the “score +1” to happen too many times. It’s almost like they are hitting the character a few times before being registered as “hit” and disappearing. Any ideas how to fix this?
function preyHandler(event:Event)
{// handler for prey getting eaten
for (var i:int=0; i<allPrey.length; i++)
{
if (event.target.hitTestObject(hitMc))
{
//trace ("hit test successful");
event.target.width = 0;
event.target.height = 0;
preyCount++;
trace("score +1");
score.text = String(preyCount);
event.target.removeEventListener(Event.ENTER_FRAME, preyHandler);
}
}
}//end preyHandler