0

I have a HitTestObject that will remove the movieClip(enemy) when hit with a bullet.

This is the code:

if (hitTestObject(bulletTarget)) {
    //remove this from the stage if it touches a bullet
    removeEventListener(Event.ENTER_FRAME, eFrame);
    _root.removeChild(this);
    //also remove the bullet and its listeners
    _root.bulletContainer.removeChild(bulletTarget);
    bulletTarget.removeListeners();
    //up the score
    _root.score += 5;
}

But instead of removing it immediately, I want the Movieclip(enemy) to play the next frame, which is an animation of it exploding, and once the explosion has happened it should be removed.

1 Answer 1

0

Silly me!

I changed

_root.removeChild(this);

to

this.gotoAndPlay(2);

and then at the end of my explosion clip I added

this.parent.removeChild(this);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.