I’m making an educational side-scrolling game where basically one animal “eats” other aquatic animals on the stage. Right now, it counts as a hit when anywhere on the entire movieclip for the character (“char”) touches one of the prey. How do I make just the head count?
function preyHandler(event:Event)
{// handler for prey getting eaten
for (var i:int=0; i<allPrey.length; i++)
{
if (event.target.hitTestObject(char))
{
//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
I made a clip inside “char” called “head” and tried
if (event.target.hitTestObject(char.head))
and event just
if (event.target.hitTestObject(head))
but those made crazy errors.
What is the correct way to do this? Any help appreciated.