Hi I’m new here so it wouldn’t surprise me if I miss something simple but here goes:
I am creating a game where you have to catch coconuts in a basket and when this happens the next one will fall (removechild() ). And the score is incremented etc…
My problem is that when it reaches the third coconut it freezes I feel that there is a flaw in my logic but I cannot see it for some reason:
function collisionDetector(event:Event):void {
//Create the children to be deleted later
addChild(coco1_mc);
addChild(coco2_mc);
addChild(coco3_mc);
if ( coco1_mc.hitTestObject(basket_mc) ) {
coco_hits += 1;
updateHitText();
coco3_mc.y += dy; //Code for movement(function declared earlier)
removeChild(coco1_mc);
}
else if ( coco1_mc.hitTestObject(bottomz) ) {
coco_miss += 1;
updateHitText();
coco3_mc.y += dy;
removeChild(coco1_mc);
}
if (coco3_mc.hitTestObject(basket_mc) ) {
coco_hits += 1;
updateHitText();
coco5_mc.y += dy;
removeChild(coco3_mc);
}
else if (coco3_mc.hitTestObject(bottomz) ) {
coco_miss++;
updateHitText();
coco5_mc.y += dy;
removeChild(coco3_mc);
}
Any help would be appreciated, thanks, Tom