Page 1 of 1

Destroy all enemies on screen

PostPosted: Tue Mar 05, 2013 1:14 pm
by lverona
I want to have a weapon in the game which will destroy all enemies on screen at once.

For each enemy I have a DeathEnemyX() function, like DeathBase1(), DeathBase2(), etc., each of which places the explosions in the correct spots and such.

In order to achieve that I decided to create an actor which would be the size of the window, 640x480, not drawn but accepting events. I made sure that each enemy has a Collision event with that actor, in which I called the DeathEnemyX() function.

However, for some reason, when I press the button and the "bomb" goes off, only one enemy is destroyed. And I can destroy all of them by pressing the fire button several times.

What am I doing wrong here?
Is there a better way?

Re: Destroy all enemies on screen

PostPosted: Tue Mar 05, 2013 3:19 pm
by moonforge
I have an idea, but it could be completely wrong. Here it goes:

You create a region actor that has the view be its parent. Then, you have it so that all enemies in the region have the ability to be destroyed when you shoot a bomb. If you need more help, leave a reply asking for more.

Re: Destroy all enemies on screen

PostPosted: Tue Mar 05, 2013 3:35 pm
by lverona
I did locate a bug in my approach - I had a Destroy Collide Actor in the function, so my "bomb" would get destroyed by the first enemy it touched upon. Fixing it right now.

Re: Destroy all enemies on screen

PostPosted: Wed Mar 06, 2013 6:15 am
by lverona
Okay, so I managed to realize it the way I described above. I did have to redo my DeathEnemyX functions, but it works now and works very well. Yay!