I'm currently trying to detect a collision with a spawned movie clip, shown below;
function fruitCollide(e:Event):void
{
if(player_mc.hitTestObject(myApple))
{
trace("Hit!")
player_mc.removeEventListener(Event.ENTER_FRAME, moveThePlayer);
currentWordSpawn = "apple";
spawnText();
}
}
The things the player is colliding with are defined earlier in the program;
//Movie Clip Spawns
var myApple = new apple();
var myPear = new pear();
var myTomato = new tomato();
var myWatermelon = new watermelon();
The above spawns fine on the screen, however when the player walks over them, nothing happens. The player actually goes behind the spawned fruit, and there is no collision detected.
What have I done wrong? How do I detect a collision with a movie clip spawned via code?
Thanks for any help.