[Resolved] Destroying spawned objects

Get help using Construct 2

Post » Mon Feb 25, 2013 8:44 am

During the course of my game, I will have plenty of sprites being spawned on top of other sprites (ie. if you set an enemy on fire, spawn fire sprite. if an enemy detects you, spawn ! sprite). Normally when I destroy a sprite, I can use a "On Sprite1 destroyed - if sprite1 is overlapping sprite2, destroy sprite2" and it works. But what do I do if sometimes multiple instances of Sprite1 will be overlapping each other (which is always a random occurrence)?

All of the sprites I spawn are pinned 99% of the time. Is there an event to check if an item is pinned to another object? (if I use Sprite2 is Pinned, it destroys ALL of them in the layout)ome6a17172013-02-25 19:47:17
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Mon Feb 25, 2013 9:31 am

Pin Behavior

When you destroy an object, check for any other objects who's PinnedUID which match the UID of the sprite being descriptor and destroy those.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Mon Feb 25, 2013 7:23 pm

I'm trying to use it like this:

On Sprite1 Destroyed
For Each Sprite1
Pick Sprite2 Instance with UID "Sprite2.Pin.PinUID"

-Destroy Sprite2

It doesn't seem to be working. What am I doing wrong?
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Mon Feb 25, 2013 7:39 pm

On Sprite1 Destroyed
For each Sprite2
Compare two values: Sprite2.Pin.PinnedUID = Sprite1.UID

-Destroy Sprite2
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Mon Feb 25, 2013 7:46 pm

You guys are amazing - thank you!
B
22
S
3
Posts: 451
Reputation: 2,135


Return to How do I....?

Who is online

Users browsing this forum: Radulepy and 5 guests