Destroy all instances of an object

For questions about using Classic.

Post » Fri Apr 08, 2011 6:37 am

What am I trying to achieve: If a bullet hits sprite2, all bullets must be destroyed. Here:

http://img801.imageshack.us/i/forallbulletsdestroy.png/

But this doesn't work. Normally, if I want to iterate through all instances in Construct, how do I do that?
B
2
G
1
Posts: 38
Reputation: 526

Post » Fri Apr 08, 2011 9:08 am

System -> On Collision (Advanced) -> Don't Pick
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Fri Apr 08, 2011 10:13 am

I see... so it's not implemented in Construct 2 yet.
B
2
G
1
Posts: 38
Reputation: 526

Post » Fri Apr 08, 2011 10:31 am

in c2, you could create a variable outside of 'bullet' that is changed by 'bullet'.

eg;

[code:2pl8qfh6]background.bullet_hit_sprite2 (boolean set to false at start up)

event: bullet collides with sprite2 >
action...your stuff
action...set background.bullet_hit_sprite2 to 'true'

event: bullet (object) > if background.bullet_hit_sprite2 = 'true' >
action...destroy self[/code:2pl8qfh6]

i think this will work. it should help you get around 'picking' for now.

hope it helps...
B
52
S
17
G
15
Posts: 1,029
Reputation: 26,339


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests