Enemies do not removed from the scene if clicked with the mouse.

I encountered another problem, I wrote the code for when I click on an enemy, it does not add one point to the score and it does not remove the enemy, I have a textfield called messageDisplay which is linked to the clickEnemy function.

Here is the piece of code.

stage.addEventListener (MouseEvent.CLICK, clickEnemy);
function clickEnemy(event:MouseEvent):void
{
If (Cursor.hitTestObject (enemyAppear))
{
Note ++
messageDisplay.text = String (score);
enemyAppear.parent.removeChild (enemyAppear);
}
}
stage.removeEventListener (MouseEvent.CLICK, clickEnemy);

Any help is appreciated, thanks Casey.

you remove your click listener so that it never works.  Difficulty to fix your problem.

Tags: Adobe Animate

Similar Questions

Maybe you are looking for