Destroy sprites

Get help using Construct 2

Post » Tue Nov 05, 2013 9:16 pm

I have 10 (ten) sprite enemies and I have the event below:

spriteShot On Colision with spriteEnemy -> spriteEnemy Destroy


The problem is that I want to destroy all the enemies in my game when a I have the colision above (NOT only the enemy hit by shot).

How can I do that ?

   Jos Roberto.
B
4
Posts: 26
Reputation: 277

Post » Tue Nov 05, 2013 11:52 pm

an easy work around is turn the trigger into global event

so make the trigger change a variable
and when variable is changed, then destroy object.
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Wed Nov 06, 2013 12:25 am

I would use a function. If you have a DestroyAllEnemy routine, you can call it, which will operate without the have a sprite picked.

Then you can just CallFunction from your On Collision event. Plus, it's reusable.



Here, here's a simple example:
https://db.tt/3pxTNdBMPixelHero2013-11-06 00:41:40
B
15
S
5
G
2
Posts: 24
Reputation: 2,054

Post » Wed Nov 06, 2013 12:46 am

Just use families.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Wed Nov 06, 2013 1:15 am

Thanks PixelHero. A Function really solved the problem.
B
4
Posts: 26
Reputation: 277

Post » Wed Nov 06, 2013 4:18 am

Another alternative to a function is to use the system condition "pick all". So your event could look like this:

spriteShot: On Colision with spriteEnemy
system: pick all spriteEnemy
---> spriteEnemy Destroy
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Wed Nov 06, 2013 4:38 am

[QUOTE=R0J0hound] Another alternative to a function is to use the system condition "pick all". So your event could look like this:

spriteShot: On Colision with spriteEnemy
system: pick all spriteEnemy
---> spriteEnemy Destroy[/QUOTE]

You know, you'd think I notice something that obvious. If you aren't interested in re-use, that's definitely the most direct method, and less error prone (you can't misspell it)
B
15
S
5
G
2
Posts: 24
Reputation: 2,054


Return to How do I....?

Who is online

Users browsing this forum: David181, evillair and 51 guests